Instance Method

loadFriendsWithCompletionHandler:

Retrieves a list of player identifiers for the local player’s friends.

Declaration

- (void)loadFriendsWithCompletionHandler:(void (^)(NSArray<NSString *> *friendIDs, NSError *error))completionHandler;

Parameters

completionHandler

A block to be called when the request completes.

The block receives the following parameters:

friendIDs

An array of NSString objects containing the player identifiers for the players that are friends of the local player. If an error occurred, this value can be non-nil. In that case, the array contains the data that Game Kit was able to download before the error occurred.

error

If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.

Discussion

When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread.

Once this call is completed, the friends property of the shared local player object is set to the same list of players returned in the completion handler.

See Also

Deprecated Methods and Properties

- authenticateWithCompletionHandler:

Authenticates the local player on the device.

Deprecated
friends

An array of NSString objects containing the player identifiers for the local player’s friends.

Deprecated
- loadDefaultLeaderboardCategoryIDWithCompletionHandler:

Loads the category identifier for the local player’s default leaderboard.

Deprecated
- loadFriendPlayersWithCompletionHandler:

Retrieves a list of player identifiers for the local player’s friends.

Deprecated
- setDefaultLeaderboardCategoryID:completionHandler:

Sets the category identifier for the local player’s default leaderboard.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software