崩溃日志: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;
}
}];