- (void)lookupPlayers {
NSLog(@"Looking up %lu players...", (unsigned long)match.players.count);
// Error on the below line
[GKPlayer loadPlayersForIdentifiers:match.players withCompletionHandler:^(NSArray *players, NSError *error) { {
if (error != nil) {
NSLog(@"Error retrieving player info: %@", error.localizedDescription);
matchStarted = NO;
[delegate matchEnded];
} else {
// Populate players dict
self.playersDict = [NSMutableDictionary dictionaryWithCapacity:players.count];
for (GKPlayer *player in players) {
NSLog(@"Found player: %@", player.alias);
[playersDict setObject:player forKey:player.playerID];
}
// Notify delegate match can begin
matchStarted = YES;
[delegate matchStarted];
}
}];
答案 0 :(得分:1)
阅读GKPlayer loadPlayersForIdentifiers:withCompletionHandler:
的文档。标识符数组必须是NSString
的数组,但是您传入的数组为GKPlayer
。
你可以这样做,从玩家阵列中获取一系列玩家ID:
NSArray *playerIds = [match.players valueForKey:@"playerID"];
然后将playerIds
代替match.players
传递给loadPlayersForIdentifiers:withCompletionHandler:
。