GKMatchmakerViewControllerDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in iOS 4.0 and later.
Companion guide
Declared in
GKMatchmakerViewController.h

Overview

A class implements the GKMatchmakerViewControllerDelegate protocol to receive notifications from a GKMatchmakerViewController object. The delegate is called if a new match has been successfully created, if the user cancels matchmaking, and if an error occurs. In all three cases, the delegate should dismiss the view controller.

Tasks

Completing a Match Request

Handling Cancellations

Handling Errors

Hosted Matches

Instance Methods

matchmakerViewController:didFailWithError:

Called when the view controller encounters an unrecoverable error. (required)

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error
Parameters
viewController

The view controller that received the error.

error

An error object that describes the error.

Availability
  • Available in iOS 4.1 and later.
Declared In
GKMatchmakerViewController.h

matchmakerViewController:didFindMatch:

Called when a peer-to-peer match is found.

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
Parameters
viewController

The view controller that performed the matchmaking.

match

A completed match.

Discussion

This method is called when the view controller’s hosted property is NO. Although optional in the protocol, if your game attaches a delegate to the view controller for a peer-to-peer match, the view controller expects your game to provide an implementation of this method.

Availability
  • Available in iOS 4.1 and later.
Declared In
GKMatchmakerViewController.h

matchmakerViewController:didFindPlayers:

Called when a hosted match is found.

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindPlayers:(NSArray *)playerIDs
Parameters
viewController

The view controller that performed the matchmaking.

playerIDs

An array of NSString objects containing player identifier for the matched players.

Discussion

This method is called when the view controller’s hosted property is YES. Although optional in the protocol, if your game attaches a delegate to the view controller for a hosted match, the view controller expects your game to provide an implementation of this method.

The view controller returns the list of players to your game by calling this method. Your game is responsible for connecting these players to your own server and then using that server to relay messages between the players.

Availability
  • Available in iOS 4.1 and later.
Declared In
GKMatchmakerViewController.h

matchmakerViewController:didReceiveAcceptFromHostedPlayer:

Called when a player in a hosted match accepts the invitation.

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didReceiveAcceptFromHostedPlayer:(NSString *)playerID
Parameters
viewController

The view controller that accepted the invitation..

playerID

The identifier of the accepting player.

Discussion

After a player accepts an invitation, that player’s device should connect to your server. Once the connection is established, your game should call the view controller’s setHostedPlayer:connected: method to update the player’s connection status.

Availability
  • Available in iOS 5.0 and later.
Declared In
GKMatchmakerViewController.h

matchmakerViewControllerWasCancelled:

Called when the user cancels the matchmaking request (required)

- (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController *)viewController
Parameters
viewController

The view controller that received the cancellation.

Availability
  • Available in iOS 4.1 and later.
Declared In
GKMatchmakerViewController.h