iOS Developer Library

Developer

GameKit Framework Reference GKTurnBasedEventListener Protocol Reference

Options
Deployment Target:

On This Page
Language:

GKTurnBasedEventListener

Handles events for turn-based games. Provides methods for responding to exchanges and match events. More...

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


import GameKit @import GameKit;

Availability


Available in iOS 7.0 and later.
  • Initiates a match from Game Center with the requested players. (required)

    Declaration

    Swift

    optional func player(_ player: GKPlayer!, didRequestMatchWithOtherPlayers playersToInvite: [AnyObject]!)

    Objective-C

    - (void)player:(GKPlayer *)player didRequestMatchWithOtherPlayers:(NSArray *)playersToInvite

    Parameters

    player

    The GKPlayer object containing the current player’s information.

    playersToInvite

    An array of GKPlayer objects containing the player identifiers to invite to the match.

    Discussion

    When this method is called, you should create a new match using the player identifiers provided and present a GKTurnBasedMatchmakerViewController.

    Import Statement

    import GameKit

    Availability

    Available in iOS 8.0 and later.

  • Called when the match has ended. (required)

    Declaration

    Swift

    optional func player(_ player: GKPlayer!, matchEnded match: GKTurnBasedMatch!)

    Objective-C

    - (void)player:(GKPlayer *)player matchEnded:(GKTurnBasedMatch *)match

    Parameters

    player

    The GKPlayer object containing the current player’s information.

    match

    The GKTurnBasedMatch object containing the current game data.

    Import Statement

    import GameKit

    Availability

    Available in iOS 7.0 and later.

  • Activates the player’s turn. (required)

    Declaration

    Swift

    optional func player(_ player: GKPlayer!, receivedTurnEventForMatch match: GKTurnBasedMatch!, didBecomeActive didBecomeActive: Bool)

    Objective-C

    - (void)player:(GKPlayer *)player receivedTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive

    Parameters

    player

    The GKPlayer object containing the current player’s information.

    match

    The GKTurnBasedMatch object containing the current game data.

    didBecomeActive

    Denotes whether the app should be launched or brought to the foreground.

    Discussion

    This method is called when the it becomes the player’s turn. It is also called when any of the following events happen:

    • The current turn has a time-out associated with it and the turn is about to expire.

    • Player accepts an invite from another player.

    • Turn was passed to another player. In this case, didBecomeActive is false.

    • Match data is saved by another player.

    • Player receives a reminder.

    Import Statement

    import GameKit

    Availability

    Available in iOS 7.0 and later.

  • Initiates a match from Game Center with the requested players. (required)

    Declaration

    Swift

    optional func player(_ player: GKPlayer!, didRequestMatchWithPlayers playerIDsToInvite: [AnyObject]!)

    Objective-C

    - (void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray *)playerIDsToInvite

    Parameters

    player

    The GKPlayer object containing the current player’s information.

    playerIDsToInvite

    An array of NSString objects containing the player identifiers to invite to the match.

    Discussion

    When this method is called, you should create a new match using the player identifiers provided and present a GKTurnBasedMatchmakerViewController.

    Import Statement

    import GameKit

    Availability

    Available in iOS 7.0 and later.

    Deprecated in iOS 8.0.