I’m working With Game Center right now and I have a issue with GC.
When I’m using initWithPlayerIDs:, I don’t get any score when loadScoresWithCompletionHandler: callback is called.
GKLeaderboard *leaderBoard = [[[GKLeaderboard alloc] initWithPlayerIDs:[NSArray arrayWithObject:gcPlayerID]] autorelease];
leaderBoard.timeScope = GKLeaderboardTimeScopeAllTime;
leaderBoard.category = @"SomeLeaderboard";
[leaderBoard loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error == nil)
{
// scores is null
// ...
}
But when I’m doing:
GKLeaderboard *leaderBoard = [[[GKLeaderboard alloc] init] autorelease];
leaderBoard.timeScope = GKLeaderboardTimeScopeAllTime;
leaderBoard.category = @"SomeLeaderboard";
[leaderBoard loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error == nil)
{
for (GKScore* score in scores)
if ([score.playerID isEqualToString:gcPlayerID])
{
// Got something here
return;
}
}
It’s working.
I’m using the 2nd method at the moment but it will make time to process if there is many score.
Does anyone have the same issue ?
Thanks.
I’m afraid that with the given info I don’t have an answer as to why
initWithPlayerIDs:is not working. However, I might be able to simplify your filtering for the local player score in the 2nd method. AGKLeaderboardhas a propertylocalPlayerScorethat is valid only afterloadScoresWithCompletionHandler:has completed.localPlayerScorethen gives theGKScorefor the local player. Your 2nd method would then look like this:Hope this helps a little.