FBSDKGraphRequestConnection
Versi yang lebih baru dari kelas ini sudah tersedia. Lihat versi terbaru.

The FBSDKGraphRequestConnection represents a single connection to Facebook to service a request.

Discussion:

The request settings are encapsulated in a reusable FBSDKGraphRequest object. The FBSDKGraphRequestConnection object encapsulates the concerns of a single communication e.g. starting a connection, canceling a connection, or batching requests.

Superclass:NSObject
Declared in:FBSDKGraphRequestConnection.h
Properti
delegate

The delegate object that receives updates.

@property (nonatomic, weak) id<FBSDKGraphRequestConnectionDelegate> delegate;
timeout

Gets or sets the timeout interval to wait for a response before giving up.

@property (nonatomic) NSTimeInterval timeout;
URLResponse

The raw response that was returned from the server. (readonly)

@property (nonatomic, retain, readonly) NSHTTPURLResponse *URLResponse;
Discussion:

This property can be used to inspect HTTP headers that were returned from the server. The property is nil until the request completes. If there was a response then this property will be non-nil during the FBSDKGraphRequestHandler callback.

Metode Kelas
setDefaultConnectionTimeout:

This method sets the default timeout on all FBSDKGraphRequestConnection instances. Defaults to 60 seconds.

ParameterKeterangan
defaultConnectionTimeout

The timeout interval.

+ (void) setDefaultConnectionTimeout:(NSTimeInterval)defaultConnectionTimeout;
Metode Instans
addRequest:completionHandler:

This method adds an FBSDKGraphRequest object to this connection.

ParameterKeterangan
request

A request to be included in the round-trip when start is called.

handler

A handler to call back when the round-trip completes or times out.

- (void)
addRequest: (FBSDKGraphRequest *)request
completionHandler: (FBSDKGraphRequestHandler)handler;
Discussion:

The completion handler is retained until the block is called upon the completion or cancellation of the connection.

addRequest:completionHandler:batchEntryName:

This method adds an FBSDKGraphRequest object to this connection.

ParameterKeterangan
request

A request to be included in the round-trip when start is called.

handler

A handler to call back when the round-trip completes or times out. The handler will be invoked on the main thread.

name

An optional name for this request. This can be used to feed the results of one request to the input of another <FBSDKGraphRequest> in the same FBSDKGraphRequestConnection as described in Graph API Batch Requests.

- (void)
addRequest: (FBSDKGraphRequest *)request
completionHandler: (FBSDKGraphRequestHandler)handler
batchEntryName: (NSString *)name;
Discussion:

The completion handler is retained until the block is called upon the completion or cancellation of the connection. This request can be named to allow for using the request's response in a subsequent request.

addRequest:completionHandler:batchParameters:

This method adds an FBSDKGraphRequest object to this connection.

ParameterKeterangan
request

A request to be included in the round-trip when start is called.

handler

A handler to call back when the round-trip completes or times out.

batchParameters

The optional dictionary of parameters to include for this request as described in Graph API Batch Requests. Examples include "depends_on", "name", or "omit_response_on_success".

- (void)
addRequest: (FBSDKGraphRequest *)request
completionHandler: (FBSDKGraphRequestHandler)handler
batchParameters: (NSDictionary *)batchParameters;
Discussion:

The completion handler is retained until the block is called upon the completion or cancellation of the connection. This request can be named to allow for using the request's response in a subsequent request.

cancel

Signals that a connection should be logically terminated as the application is no longer interested in a response.

- (void) cancel;
Discussion:

Synchronously calls any handlers indicating the request was cancelled. Cancel does not guarantee that the request-related processing will cease. It does promise that all handlers will complete before the cancel returns. A call to cancel prior to a start implies a cancellation of all requests associated with the connection.

overrideVersionPartWith:

Overrides the default version for a batch request

ParameterKeterangan
version

This is a string in the form @"v2.0" which will be used for the version part of an API path

- (void) overrideVersionPartWith:(NSString *)version;
Discussion:

The SDK automatically prepends a version part, such as "v2.0" to API paths in order to simplify API versioning for applications. If you want to override the version part while using batch requests on the connection, call this method to set the version for the batch request.

setDelegateQueue:

Determines the operation queue that is used to call methods on the connection's delegate.

ParameterKeterangan
queue

The operation queue to use when calling delegate methods.

- (void) setDelegateQueue:(NSOperationQueue *)queue;
Discussion:

By default, a connection is scheduled on the current thread in the default mode when it is created. You cannot reschedule a connection after it has started. This is very similar to [NSURLConnection setDelegateQueue:].

start

This method starts a connection with the server and is capable of handling all of the requests that were added to the connection.

- (void) start;
Discussion:

By default, a connection is scheduled on the current thread in the default mode when it is created. See setDelegateQueue: for other options. This method cannot be called twice for an FBSDKGraphRequestConnection instance.

Konstan
FBSDKNonJSONResponseProperty
FBSDK_EXTER N NSString *const FBSDKNonJSONResponseProperty;
Discussion:

When a request returns a non-JSON response (such as a "true" literal), that response will be wrapped into a dictionary using this const as the key. This only applies for very few Graph API prior to v2.1.

Typedefs
FBSDKGraphRequestHandler

A block that is passed to addRequest to register for a callback with the results of that request once the connection completes.

typedef void (^FBSDKGraphRequestHandler)(
FBSDKGraphRequestConnection *connection,
id result,
NSError *error);
Discussion:

Pass a block of this type when calling addRequest. This will be called once the request completes. The call occurs on the UI thread.