2

我正在使用游戏中心获取本地玩家朋友的信息。我已经成功获得了显示名称:

- (void)retrieveFriends {
    GKLocalPlayer *lp = [GKLocalPlayer localPlayer];
    if (lp.authenticated
    {
        [lp loadFriendsWithCompletionHandler:^(NSArray *friendIDs, NSError *error) {
            NSArray *array = [lp friends];
            [self loadPlayerData:array];
        }];
    }
}
- (void)loadPlayerData: (NSArray *)identifiers {
    [GKPlayer loadPlayersForIdentifiers:identifiers withCompletionHandler:^(NSArray *players, NSError *error) {
        if (error != nil) {
            // Handle the error.
            NSLog(@"%@", error);
        }
        if (players != nil) {
            // Process the array of GKPlayer objects.
            GKPlayer *friend = [players objectAtIndex:0];
            friends = [[NSMutableArray alloc] init];
            id name = [friend displayName];
            id score = // What do I put here?
            [friends addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:name, @"name", score, @"score", nil]];
        }
    }];

我怎样才能得到分数?我做了一些研究,但一无所获。

4

0 回答 0