我的游戏已经在 iOS5 中运行了一年。在更新它以与 iOS6 一起工作后,它现在在尝试在 Game Center 中发送分数时崩溃。reportScoreWithCompletionHandler
它在代码行中崩溃
- (void)sendScore:(GKScore *)score {
[score reportScoreWithCompletionHandler:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^(void)
{
if (error == NULL) {
NSLog(@"Successfully sent score!");
[scoresToReport removeObject:score];
} else {
NSLog(@"Score failed to send... will try again later. Reason: %@", error.localizedDescription);
}
});
}];
}
我在这里做错了什么?
更新
看了一点,似乎也可能存在问题authenticateWithCompletionHandler
......我的代码如下......如果这是罪魁祸首,我该如何更新它才能正常工作?
- (void)authenticateLocalUser {
if (!gameCenterAvailable) return;
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO) {
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil];
} else {
NSLog(@"Already authenticated!");
}
}