Game Development Reference
In-Depth Information
If you followed the leaderboard and achievement view examples, you know that each
required the GameKitHelper class to implement a protocol, and with matchmaking
it's no different. I also added GKMatchDelegate because you're going to need it
@interface GameKitHelper : NSObject < GKLeaderboardViewControllerDelegate,←
GKAchievementViewControllerDelegate, GKMatchmakerViewControllerDelegate,
GKMatchDelegate >
The GKMatchmakerViewControllerDelegate protocol requires three meth-
ods to be implemented: one for the player pressing the Cancel button, one for failing
with an error, and one for finding a suitable match. The latter deserves a mention:
-(void) matchmakerViewController:(GKMatchmakerViewController*)viewController
[self dismissModalViewController];
[self setCurrentMatch:match];
if ([delegate respondsToSelector:@selector(onMatchFound:)])
[delegate onMatchFound:match];
If a match was found, this match is set as the current match, and the delegate's
onMatchFound method is called to inform it about the newly found match.
Instead of hosting a match, you can also instruct Game Center to try to automatically
find a match for you, as shown in Listing 14-21 . If successful, the delegate receives the
same onMatchFound message.
Listing 14-21 . Searching for an Existing Match
-(void) findMatchForRequest:(GKMatchRequest*)request
if (isGameCenterAvailable == NO)
Search Nedrilad ::

Custom Search