Instance Method

saveMergedMatchData:withResolvedExchanges:completionHandler:

Saves the merged data for the current turn without ending the turn.

Declaration

- (void)saveMergedMatchData:(NSData *)matchData withResolvedExchanges:(NSArray<GKTurnBasedExchange *> *)exchanges completionHandler:(void (^)(NSError *error))completionHandler;

Parameters

matchData

A serialized blob of data reflecting the current state for the match.

exchanges

An array of GKTurnBasedExchange objects that contains the resolved exchanges.

completionHandler

A block to be called after the scores are saved to the server.

The block receives the following parameters:

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.

When this method is called, the data sent is marked as being resolved. This means that the data has been merged into the match data. If other players currently have the game running, they will receive a handleTurnEventForMatch call to indicate that matchData has changed. All completed exchanges must be resolved before ending a turn. If the completed exchanges have not been resolved, then calling endTurn, participantQuitInTurnWithOutCome, or endMatchInTurn will result in an error.

See Also

Transferring Information with Exchanges

GKExchangeTimeoutDefault

The exchange will timeout after one day if no reply is received.

GKExchangeTimeoutNone

The exchange will not timeout.

activeExchanges

Returns the exchanges that are active for the local player.

completedExchanges

The exchanges that have been completed and need to be merged by the local participant.

exchangeDataMaximumSize

The maximum amount of data allowed for an exchange.

exchangeMaxInitiatedExchangesPerPlayer

Limits the number of exchanges the player can have initiated at once.

exchanges

The current exchanges that are in progress for the match.