0

Crash log: A GKScore must specify a leaderboard.

When I try it in sandbox, it works ok, in App Store version it crashes.

- (void)reportScoreToGameCenter
{
    NSString *totalPoints = [[NSUserDefaults standardUserDefaults] objectForKey:TotalPointsUserDefaultsKey];
    GKScore *score = [[GKScore alloc] initWithLeaderboardIdentifier:[GCHelper sharedInstance].leaderboardIdentifier];
    score.value = [totalPoints integerValue];

    [GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
//        if (error != nil) {
//            NSLog(@"%@", [error localizedDescription]);
//        }
    }];
}

LeaderboardIdentifier is obtained via:

[[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {
            NSLog(@"Leaderboard identifier: %@", leaderboardIdentifier);
            if (error != nil) {
                NSLog(@"%@", [error localizedDescription]);
            }
            else{
                self.leaderboardIdentifier = leaderboardIdentifier;
            }
        }]; 
Sanjay Mohnani
  • 5,947
  • 30
  • 46
vburojevic
  • 1,666
  • 5
  • 24
  • 34

0 Answers0