Reputation: 1973
this is my code to get the default leaderboard in game center but return a nil value.
and i have this info in the iTunes connect what can i do? thanks
This image is from iTunes Connect
and the code to obtain the default leaderboard
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil) {
[self presentViewController:viewController animated:YES completion:nil];
}
else{
if ([GKLocalPlayer localPlayer].authenticated) {
_gameCenterEnabled = YES;
[[GKLocalPlayer localPlayer]loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString * _Nullable leaderboardIdentifier, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"%@",[error localizedDescription]);
}else{
_leaderboardIdentifier = leaderboardIdentifier; // **This contains nil value**
}
}];
}else{
_gameCenterEnabled=NO;
}
}
};
Upvotes: 0
Views: 322
Reputation: 1973
I solve this strange problem creating a new leaderboard and create a new version of my application for example 1.1 and this works for me.
Thanks for your answer crashoverride777
Upvotes: 0
Reputation: 10674
You code looks fine. Did you try signing out and back into Game Center on your device? I have this happening to me a few times in sandbox mode as well and a signing out and back in usually fixes it.
Upvotes: 1