Mac Developer Library

Developer

GameKit Framework Reference GKTurnBasedEventHandlerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

GKTurnBasedEventHandlerDelegate

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import GameKit

Objective-C

@import GameKit;

Availability


Available in OS X v10.8 and later.
Deprecated in OS X v10.10.

The GKTurnBasedEventHandlerDelegate protocol is implemented by an object to receive notifications events for turn-based matches. All methods are called on the main thread.

This protocol has been deprecated in iOS 7, use GKTurnBasedEventListener.

  • Sent to the delegate when the local player receives an invitation to join a new turn-based match.

    Declaration

    Swift

    func handleInviteFromGameCenter(_ playersToInvite: [AnyObject]!)

    Objective-C

    - (void)handleInviteFromGameCenter:(NSArray *)playersToInvite

    Parameters

    playersToInvite

    An array of NSString objects containing the player identifiers for the players to initially invite to the game.

    Discussion

    When your delegate receives this message, your game should create a new GKMatchRequest object and assign the playersToInvite parameter to the match request’s playersToInvite property. Then, your game can either call the GKTurnBasedMatch class method findMatchForRequest:withCompletionHandler: to find a match programmatically or it can use the request to instantiate a new GKTurnBasedMatchmakerViewController object to show a user interface to the player.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Sent to the delegate when it is the local player’s turn to act in a turn-based match.

    Deprecation Statement

    Implement handleTurnEventForMatch:didBecomeActive: instead.

    Declaration

    Objective-C

    - (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match

    Parameters

    match

    A match object containing the current state of the match.

    Discussion

    When your delegate receives this message, the player has accepted a push notification for a match already in progress. Your game should end whatever task it was performing and switch to the match information provided by the match object.

    Import Statement

    Objective-C

    @import GameKit;

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.9.

  • Sent to the delegate when it is the local player’s turn to act in a turn-based match.

    Declaration

    Swift

    func handleTurnEventForMatch(_ match: GKTurnBasedMatch!, didBecomeActive didBecomeActive: Bool)

    Objective-C

    - (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive

    Parameters

    match

    A match object containing the current state of the match.

    didBecomeActive

    YEStrue if the game was launched or brought to the foreground to handle the event.

    Discussion

    When your delegate receives this message, the player has accepted a push notification for a match already in progress. Your game should end whatever task it was performing and switch to the match information provided by the match object.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.9 and later.

    Deprecated in OS X v10.10.

  • Sent to the delegate when a match the local player is participating in has ended.

    Declaration

    Swift

    optional func handleMatchEnded(_ match: GKTurnBasedMatch!)

    Objective-C

    - (void)handleMatchEnded:(GKTurnBasedMatch *)match

    Parameters

    match

    The match that just ended.

    Discussion

    When your delegate receives this message, it should display the match’s final results to the player and allow the player the option of saving or removing the match data from Game Center.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.