Game Center integration
Matchmaker, matchmaker find me a match! Now's the time to start finding our friends!
Let's pop over to our MultiplayerHelper.h
file so that we can add in a new dictionary to store the players we find. Just after the @interface
line, add in the following declaration:
@property(nonatomic, strong) NSMutableDictionary *playersDict;
This dictionary allows Game Kit to easily look up player data.
Now, we will go over to our MultiplayerHelper.m
file and make a few new changes. First, we will add a new method just after we authenticate our local player:
- (void)lookupPlayers { NSLog(@"Looking up %lu players...", (unsigned long)_match.playerIDs.count); [GKPlayer loadPlayersForIdentifiers:_match.playerIDs withCompletionHandler:^(NSArray *players, NSError *error) { if (error != nil) { NSLog(@"Error retrieving player info: %@", error.localizedDescription); _matchStarted = NO; [_delegate matchEnded]; } else...