I am working with Game Center, and I know it's easy enough to present the Game Center view controller to show all of a player's open (turn-based) matches. But I would like to also show the number of matches the user is currently involved in, and give quick links to open those matches without using the Game Center view controller. Is there a way to do this?
问问题
558 次
1 回答
3
You can use the following method to retrieve the list of matches from the Game Center:
GKTurnBasedMatch loadMatchesWithCompletionHandler
I have attached a code snippet to show how I am loading them. GameKitHelper is a singleton I use to perform some common Game Kit actions. I also request the player aliases to display them with the match info.
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error)
{
if (error)
{
NSLog(@"Load matches error: %@", error.description);
// more error processing here
return;
}
self.currentMatches = matches;
// upate all the matches match data, then end any orphan matches, then get player aliases
// it is very important to update all the match data, because the loadMatchesWithCompletionHandler
// will have no match data, or old match data.
[GameKitHelper updateMatchesMatchData:self.currentMatches completionHandler:^(NSError *error) {
[GameKitHelper endOrphanedMatches:matches completionHandler:^(NSError *error) {
[self requestPlayerAliasesFromGameCenterForMatches:self.currentMatches];
}];
}];
}];
于 2012-12-19T00:14:55.943 回答