iOS GameKit Leaderboard - Get the localplayer's score +/- 50 players around him
I'm programmatically pulling down leaderboard data from g开发者_JS百科ame center and I'd like to limit my data query to the local player's score and the 25 scores above and below him. Is this possible. Is there a way to get the local player's current position in the leaderboard?
Once you make a call to [GKLeaderboard loadScoresWithCompletionHandler:]
you can use [[GKLeaderboard localPlayerScore] rank]
to get the rank of the current user.
So the next time you call loadScoresWithCompletionHandler
, set the range around that value like leaderboardRequest.range=NSMakeRange(localPlayerRank-25, 50)
Also make sure you're not querying for a rank less than one!
精彩评论