我想在我的游戏首页上显示一个非常小的排行榜片段,基本上显示你的分数和你周围的两个朋友的分数(高于和低于你的分数)。我已经阅读了苹果文档并且看不到这样做的方法,除非我指定所有朋友并指定一个很大的范围以确保我得到所有朋友,然后我可以过滤。检索此列表似乎效率低下,尤其是当用户可能在移动设备上时。如何在不下载整个好友列表然后过滤的情况下实现我想要的?
这是我目前拥有的(没有过滤)
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil)
{
leaderboardRequest.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardRequest.category = @"HighScore";
leaderboardRequest.range = NSMakeRange(1,100);
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil)
{
// Handle the error.
}
if (scores != nil)
{
GKScore* myScore = leaderboardRequest.localPlayerScore;
NSLog(@"Me: %@: %d",myScore.playerID, (int)myScore.value);
// Process the score information - here I would filter
for (GKScore* score in scores)
{
NSLog(@"%@: %d",score.playerID, (int)score.value);
}
}
}];
}