iOS Developer Library

Developer

GameKit Framework Reference GKTurnBasedParticipant Class Reference

Options
Deployment Target:

On This Page
Language:

GKTurnBasedParticipant

Inheritance


Conforms To


Import Statement


Swift

import GameKit

Objective-C

@import GameKit;

Availability


Available in iOS 5.0 and later.

A GKTurnBasedParticipant object stores information for a participant in a turn-based match. Your game never creates objects of this class directly; instead it retrieves an array of GKTurnBasedParticipant objects from a GKTurnBasedMatch object.

Most information stored in a GKTurnBasedParticipant object is read-only, and is provided by GameKit to assist you in implementing your game logic. However, the matchOutcome property is quite important; before your game ends a match, it must set the matchOutcome property for every participant in the match.

Subclassing Notes

This class may not be subclassed.

  • The date and time that this participant last took a turn in the game. (read-only)

    Declaration

    Swift

    @NSCopying var lastTurnDate: NSDate! { get }

    Objective-C

    @property(readonly, copy, nonatomic) NSDate *lastTurnDate

    Discussion

    The value of this property is invalid until the participant first takes a turn in the match.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 5.0 and later.

  • player player Property

    The GKPlayer object that identifies this participant. (read-only)

    Declaration

    Swift

    var player: GKPlayer! { get }

    Objective-C

    @property(readonly, retain, nonatomic) GKPlayer *player

    Discussion

    The value of this property may be nil if this slot in the match has not yet been filled by an actual player.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 8.0 and later.

  • status status Property

    The current status of the participant. (read-only)

    Declaration

    Swift

    var status: GKTurnBasedParticipantStatus { get }

    Objective-C

    @property(readonly, nonatomic) GKTurnBasedParticipantStatus status

    Discussion

    This property is updated by GameKit to reflect the current status of the local player.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 5.0 and later.

  • The date and time that the participant’s turn timed out. (read-only)

    Declaration

    Swift

    @NSCopying var timeoutDate: NSDate! { get }

    Objective-C

    @property(readonly, copy, nonatomic) NSDate *timeoutDate

    Discussion

    This property will be non-nil for participants whose turns have timed out. When a new turn is taken, this property is reset to nil.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 6.0 and later.

  • playerID playerID (iOS 8.0) Property

    The player identifier for this participant. (read-only)

    Declaration

    Swift

    var playerID: String! { get }

    Objective-C

    @property(readonly, copy, nonatomic) NSString *playerID

    Discussion

    The value of this property may be nil if this slot in the match has not yet been filled by an actual player.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 5.0 and later.

    Deprecated in iOS 8.0.

  • The end-state of this participant in the match.

    Declaration

    Swift

    var matchOutcome: GKTurnBasedMatchOutcome

    Objective-C

    @property(assign, nonatomic) GKTurnBasedMatchOutcome matchOutcome

    Discussion

    Initially, this property holds GKTurnBasedMatchOutcomeNone. Before your game can end a match, it must set the match outcome to a value that reflects the outcome of this participant when he or she left the match. See “Match Outcomes”. Optionally, it may also use an OR operation to include a custom match outcome for your specific game. Game Center does not use the custom value; it exists to allow your game to store its own information about the end of the match. The custom value must fit in the range provided by the GKTurnBasedMatchOutcomeCustomRange constant.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 5.0 and later.

  • The state the participant was in when they left the match.

    Declaration

    Swift

    enum GKTurnBasedMatchOutcome : Int { case None case Quit case Won case Lost case Tied case TimeExpired case First case Second case Third case Fourth case CustomRange }

    Objective-C

    enum { GKTurnBasedMatchOutcomeNone = 0, GKTurnBasedMatchOutcomeQuit = 1, GKTurnBasedMatchOutcomeWon = 2, GKTurnBasedMatchOutcomeLost = 3, GKTurnBasedMatchOutcomeTied = 4, GKTurnBasedMatchOutcomeTimeExpired = 5, GKTurnBasedMatchOutcomeFirst = 6, GKTurnBasedMatchOutcomeSecond = 7, GKTurnBasedMatchOutcomeThird = 8, GKTurnBasedMatchOutcomeFourth = 9, GKTurnBasedMatchOutcomeCustomRange = 0x00FF0000 }; typedef NSInteger GKTurnBasedMatchOutcome;

    Constants

    • None

      GKTurnBasedMatchOutcomeNone

      The participant’s outcome has not been set yet (typically because the match is still in progress).

      Available in iOS 5.0 and later.

    • Quit

      GKTurnBasedMatchOutcomeQuit

      The participant forfeited the match.

      Available in iOS 5.0 and later.

    • Won

      GKTurnBasedMatchOutcomeWon

      The participant won the match.

      Available in iOS 5.0 and later.

    • Lost

      GKTurnBasedMatchOutcomeLost

      The participant lost the match.

      Available in iOS 5.0 and later.

    • Tied

      GKTurnBasedMatchOutcomeTied

      The participant tied the match.

      Available in iOS 5.0 and later.

    • TimeExpired

      GKTurnBasedMatchOutcomeTimeExpired

      The participant was ejected from the match because he or she did not act in a timely fashion.

      Available in iOS 5.0 and later.

    • First

      GKTurnBasedMatchOutcomeFirst

      The participant finished first.

      Available in iOS 5.0 and later.

    • Second

      GKTurnBasedMatchOutcomeSecond

      The participant finished second.

      Available in iOS 5.0 and later.

    • Third

      GKTurnBasedMatchOutcomeThird

      The participant finished third.

      Available in iOS 5.0 and later.

    • Fourth

      GKTurnBasedMatchOutcomeFourth

      The participant finished fourth.

      Available in iOS 5.0 and later.

    • CustomRange

      GKTurnBasedMatchOutcomeCustomRange

      A mask used to allow your game to provide its own custom outcome. Any custom value must fit inside the mask.

      Available in iOS 5.0 and later.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 5.0 and later.

  • The state the participant is in during the match.

    Declaration

    Swift

    enum GKTurnBasedParticipantStatus : Int { case Unknown case Invited case Declined case Matching case Active case Done }

    Objective-C

    enum { GKTurnBasedParticipantStatusUnknown = 0, GKTurnBasedParticipantStatusInvited = 1, GKTurnBasedParticipantStatusDeclined = 2, GKTurnBasedParticipantStatusMatching = 3, GKTurnBasedParticipantStatusActive = 4, GKTurnBasedParticipantStatusDone = 5, }; typedef NSInteger GKTurnBasedParticipantStatus;

    Constants

    • Unknown

      GKTurnBasedParticipantStatusUnknown

      The participant is in an unexpected state.

      Available in iOS 5.0 and later.

    • Invited

      GKTurnBasedParticipantStatusInvited

      The participant was invited to the match, but has not responded to the invitation.

      Available in iOS 5.0 and later.

    • Declined

      GKTurnBasedParticipantStatusDeclined

      The participant declined the invitation to join the match. When a participant declines an invitation to join a match, the match is automatically terminated.

      Available in iOS 5.0 and later.

    • Matching

      GKTurnBasedParticipantStatusMatching

      The participant represents an unfilled position in the match that Game Center promises to fill when needed. When you make this participant the next person to take a turn in the match, Game Center fills the position and updates the status and playerID properties.

      Available in iOS 5.0 and later.

    • Active

      GKTurnBasedParticipantStatusActive

      The participant has joined the match and is an active player in it.

      Available in iOS 5.0 and later.

    • Done

      GKTurnBasedParticipantStatusDone

      The participant has exited the match. Your game sets the matchOutcome property to state why the participant left the match.

      Available in iOS 5.0 and later.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 5.0 and later.