我在下面制作了这段代码,以从游戏中心的好友范围中获得排名。不幸的是,它只返回全局范围的等级。
...
GKLeaderboard *friendLeaderboard=[[GKLeaderboard alloc] initWithPlayers:@[[GKLocalPlayer localPlayer]]];
[friendLeaderboard setIdentifier:LeaderboardID];
[friendLeaderboard setTimeScope:GKLeaderboardTimeScopeAllTime];
[friendLeaderboard setPlayerScope:GKLeaderboardPlayerScopeFriendsOnly];
[friendLeaderboard setRange:NSMakeRange(1, 1)];
[friendLeaderboard loadScoresWithCompletionHandler:^(NSArray *friendScores, NSError *error) {
if (error) {
completionHandler(NULL, NULL);
//[scoreReporter release];//auto release added
}
else{
GKScore* gScore = [globalLeaderboard localPlayerScore];
GKScore* fScore = [friendLeaderboard localPlayerScore];
NSLog(@"GCHelper globalScores: %@", gScore);
NSLog(@"GCHelper friendScores: %@", fScore); //NOT CORRECT
completionHandler(gScore, fScore);
//[scoreReporter release];//auto release added
}
}];
...
除了循环浏览完整的朋友排行榜之外,还有正确或替代的方式吗?