Updates the data stored on Game Center for the current match.
- iOS 6.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 3.0+
An array of
GKTurnobjects reflecting the order in which the players should act next. Each object in the array must be one of the objects stored in the match’s
The length of time the next player has to complete their turn.
A serialized blob of data reflecting the game-specific state for the match. Do not pass
nilas 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
If the next player to act does not take their turn in the specified interval, the next player in the array receives a notification to act. This process continues until a player takes a turn or the last player in the list is notified.
Listing 1 shows a typical structure for this code, deferring some of the specific steps to app-specific routines that are based on your game’s actual structure. Those methods represent the places where you need to provide specific implementations in your game. The
advance method first sets a new message, then encodes the current match data as before. Finally, it calculates the order in which participants should act and calls this method to actually pass control to that list of players.
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.