0

崩溃日志:AGKScore必须指定一个leaderboard.

当我尝试它时sandbox,它可以正常工作,在App Store版本中它会崩溃。

- (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通过以下方式获得:

[[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {
            NSLog(@"Leaderboard identifier: %@", leaderboardIdentifier);
            if (error != nil) {
                NSLog(@"%@", [error localizedDescription]);
            }
            else{
                self.leaderboardIdentifier = leaderboardIdentifier;
            }
        }]; 
4

0 回答 0