Instance Method


Update the match data without advancing the game to another player.


func saveCurrentTurn(withMatch matchData: Data, completionHandler: ((Error?) -> Void)? = nil)



A serialized blob of data reflecting the game-specific state for the match. Do not pass nil as an argument.


A block to be called after the data is uploaded to Game Center.

The block receives the following parameters:


If an error occurred, this error object describes the error. If the operation was completed successfully, the value is nil.


This method updates the match data stored on Game Center. Call this method when the current player takes an action that advances the state of the match but does not end the player’s turn. For example, if your game has a fog-of-war mechanic, you might call this method when the player revealed new information on the map. Listing 1 shows a typical implementation of this method.

Listing 1

Saving the match data to Game Center

- (void) updateMatchData
// App-specific routine to encode the match data.
    NSData *updatedMatchData = [this.gameData encodeMatchData];
    [this.myMatch saveCurrentTurnWithMatchData: updatedMatchData completionHandler ^(NSError *error) {
        if (error)
            // Handle the error.

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

Handling the Current Player’s Turn