GKTurnBasedEventHandlerDelegate Protocol Reference

Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in OS X v10.8 and later.
Companion guide
Declared in
GKTurnBasedMatch.h

Overview

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.

Tasks

Receiving Turn-based Events

Instance Methods

handleInviteFromGameCenter:

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

- (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.

Availability
  • Available in OS X v10.8 and later.
Declared In
GKTurnBasedMatch.h

handleMatchEnded:

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

- (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.

Availability
  • Available in OS X v10.8 and later.
Declared In
GKTurnBasedMatch.h

handleTurnEventForMatch:didBecomeActive:

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

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

A match object containing the current state of the match.

didBecomeActive

YES 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.

Availability
  • Available in OS X v10.9 and later.
Declared In
GKTurnBasedMatch.h