Type Method

loadMatchesWithCompletionHandler:

Loads the turn-based matches involving the local player and creates a match object for each match.

Declaration

+ (void)loadMatchesWithCompletionHandler:(void (^)(NSArray<GKTurnBasedMatch *> *matches, NSError *error))completionHandler;

Parameters

completionHandler

A block to be called after the matches are retrieved from the server.

The block receives the following parameters:

matches

An array of GKTurnBased Match objects containing the match objects for matches that the local player is playing in, or nil if there are no matches to load. If an error occurred, this value may be non-nil. In this case, the array holds whatever match data could be retrieved from Game Center before the error occurred.

error

If an error occurred, this error object describes the error. If the operation was completed successfully, the value 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.

See Also

Retrieving Existing Matches