获得本地玩家朋友游戏中心的得分

时间:2013-10-30 22:48:15

标签: ios iphone objective-c game-center

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

- (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]];
        }
    }];

我如何获得分数?我做了一些研究,却一无所获。

0 个答案:

没有答案
相关问题