0

我的游戏已经在 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!");
    }
}
4

1 回答 1

1

我在这里找到了解决方案

看来您必须创建乐谱副本并提交副本。它似乎只在重新发送保存的分数时发生。这可能是因为它试图阻止您GKScore从排行榜发送?

// Pull the score value and category from the passed in score
int scoreValue = score.value;
NSString*scoreCategory = score.category;

// Create a new temporary score with these values
GKScore *toReport = [[[GKScore alloc]
initWithCategory:scoreCategory] autorelease];
toReport.value = scoreValue;
于 2013-01-11T13:32:31.877 回答