Contents

GKTurnBasedMatch

An object that encapsulates the match data for games where players take turns.

Declaration

class GKTurnBasedMatch

Mentioned in

Overview

A GKTurnBasedMatch object represents a match in a turn-based game that Game Center stores and forwards to participants in the match. In a turn-based game, participants take turns to advance gameplay until they reach an outcome. You end the match when all participants reach an outcome or they can no longer continue.

A turn-based match object contains the status of the match, list of participants, the participant whose turn it is, a message about the last turn, and your game-specific data. You can get more details about the participants through the GKTurnBasedParticipant objects in the participants property.

You don’t create turn-based match objects directly. When a match event occurs, GameKit passes the match object to listeners that conform to the GKTurnBasedEventListener protocol. Retain the match object or its match ID in the protocol methods, so you can get the latest match data later during gameplay.

Using the match object passed to GKTurnBasedEventListener protocol methods, you can perform these actions on behalf of the local player:

  • Save game data

  • End a turn

  • Forfeit a match

  • End a match

  • Send a reminder to the participant whose turn it is

  • Exchange data between participants

  • Remove a completed match from Game Center

When you end a turn, forfeit a match, or end a match, you update the match data and if gameplay can continue, choose the next participant. If you end a match, you set the individual participant outcomes as well.

If you present a GKTurnBasedMatchmakerViewController object for players to manage their turn-based matches, the player can start a match, accept an invitation, open an existing match, and forfeit a match.

Subclassing Notes

Don’t subclass the GKTurnBasedMatch class.

Topics

Creating a Match

Retrieving Match Details

Ending Turns and Saving Data

Forfeiting a Match

Ending a Match

Sending Messages Between Participants

Exchanging Data Between Participants

Loading Existing Matches

Deleting a Match from Game Center

Deprecated Methods

See Also

Turn-based games