Inherits from NSObject
Declared in FBSDKGraphRequestConnection.h

Overview

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

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.

Properties

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.

Declared In

FBSDKGraphRequestConnection.h

delegate

The delegate object that receives updates.

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

Declared In

FBSDKGraphRequestConnection.h

timeout

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

@property (nonatomic) NSTimeInterval timeout

Declared In

FBSDKGraphRequestConnection.h

Class Methods

setDefaultConnectionTimeout:

@method

+ (void)setDefaultConnectionTimeout:(NSTimeInterval)defaultConnectionTimeout

Discussion

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

  • Parameter defaultConnectionTimeout: The timeout interval.

Declared In

FBSDKGraphRequestConnection.h

Instance Methods

addRequest:completionHandler:

@method

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

Discussion

This method adds an FBSDKGraphRequest object to this connection.

  • Parameter request: A request to be included in the round-trip when start is called.
  • Parameter handler: A handler to call back when the round-trip completes or times out.

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

Declared In

FBSDKGraphRequestConnection.h

addRequest:completionHandler:batchEntryName:

@method

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

Discussion

This method adds an FBSDKGraphRequest object to this connection.

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

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

  • Parameter 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.

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.

Declared In

FBSDKGraphRequestConnection.h

addRequest:completionHandler:batchParameters:

@method

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

Discussion

This method adds an FBSDKGraphRequest object to this connection.

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

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

  • Parameter 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”.

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.

Declared In

FBSDKGraphRequestConnection.h

cancel

@method

- (void)cancel

Discussion

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

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.

Declared In

FBSDKGraphRequestConnection.h

overrideVersionPartWith:

@method

- (void)overrideVersionPartWith:(NSString *)version

Discussion

Overrides the default version for a batch request

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.

  • Parameter version: This is a string in the form @“v2.0” which will be used for the version part of an API path

Declared In

FBSDKGraphRequestConnection.h

setDelegateQueue:

Determines the operation queue that is used to call methods on the connection’s delegate. - Parameter 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:].

Declared In

FBSDKGraphRequestConnection.h

start

@method

- (void)start

Discussion

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

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.

Declared In

FBSDKGraphRequestConnection.h