FBSDKGraphRequestConnection

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
Свойства
delegate

The delegate object that receives updates.

@property (nonatomic, weak) id<FBSDKGraphRequestConnectionDelegate> delegate;
Объявлен в: FBSDKGraphRequestConnection.h
timeout

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

@property (nonatomic) NSTimeInterval timeout;
Объявлен в: FBSDKGraphRequestConnection.h
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.

Объявлен в: FBSDKGraphRequestConnection.h
Методы класса
setDefaultConnectionTimeout:

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

ПараметрОписание
defaultConnectionTimeout

The timeout interval.

+ (void) setDefaultConnectionTimeout:(NSTimeInterval)defaultConnectionTimeout;
Объявлен в: FBSDKGraphRequestConnection.h
Методы экземпляров
addRequest:completionHandler:

This method adds an FBSDKGraphRequest object to this connection.

ПараметрОписание
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.

Объявлен в: FBSDKGraphRequestConnection.h
addRequest:completionHandler:batchEntryName:

This method adds an FBSDKGraphRequest object to this connection.

ПараметрОписание
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.

Объявлен в: FBSDKGraphRequestConnection.h
addRequest:completionHandler:batchParameters:

This method adds an FBSDKGraphRequest object to this connection.

ПараметрОписание
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.

Объявлен в: FBSDKGraphRequestConnection.h
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.

Объявлен в: FBSDKGraphRequestConnection.h
overrideVersionPartWith:

Overrides the default version for a batch request

ПараметрОписание
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.

Объявлен в: FBSDKGraphRequestConnection.h
setDelegateQueue:

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

ПараметрОписание
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:].

Объявлен в: FBSDKGraphRequestConnection.h
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.

Объявлен в: FBSDKGraphRequestConnection.h
Константы
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.

Объявлен в: FBSDKGraphRequestConnection.h
Директивы Typedef
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.

Объявлен в: FBSDKGraphRequestConnection.h