Reputation: 8050
I'd like to show a player's high score in context with other players' high scores. In other words, I want to create a list that shows where the player stands compared to the competition.
The list might look something like this:
1st: 1,000,000
...
436th: 125,285
437th: 124,132 (your score)
438th: 120,998
439th: 119,212
...
1012th: 1,433
This example shows the global top and bottom scores, as well as scores neighboring the player's personal best.
Is there any way to retrieve such a list using GameKit?
EDIT/UPDATE: I slightly reworded this question and posted it to the Apple developer forums here.
Upvotes: 2
Views: 1280
Reputation: 736
Well, AFAIK there's no such way to do it in one request, but GC returns your own score in every scores request, so you can first request any (e.g. first) row in leader board, determine your own position and then create new request with positions from: your_own-desired_range to: your_own+desired_range.
_leaderboard.category = kLeaderboardID;
_leaderboard.timeScope = GKLeaderboardTimeScopeAllTime;
_leaderboard.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
_leaderboard.range = NSMakeRange(1, 1);
[_leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error){
//processing, checking errors, etc
_leaderboard.range = NSMakeRange([_leaderboard.localPlayerScore rank] - 4, 8);
[_leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error){
// Here are your results
}
}
Upvotes: 5