2013-01-11 82 views
0

我的游戏在iOS5中一年来一直处于完美状态。在更新它与iOS6一起使用后,它现在在尝试在Game Center中发送分数时崩溃。它崩溃的代码iOS6中的游戏中心崩溃

- (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);     
          } 
         }); 
    }]; 
} 

reportScoreWithCompletionHandler线我在做什么错在这里?

更新

已经观察了约一点似乎也有可能是authenticateWithCompletionHandler一个问题...我该代码如下..如果是这样责怪我怎么可以更新它,它的工作原理?

- (void)authenticateLocalUser { 

    if (!gameCenterAvailable) return; 

    NSLog(@"Authenticating local user..."); 
    if ([GKLocalPlayer localPlayer].authenticated == NO) {  
     [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil];   
    } else { 
     NSLog(@"Already authenticated!"); 
    } 
} 
+0

我们可以得到堆栈跟踪吗? –

回答

1

我找到了解决办法here

看来你必须创建分数的副本,并提交复印件。它似乎只在重新发送保存的分数时发生。这可能是因为它试图阻止你从排行榜发送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; 
+0

是的,我有同样的问题,那就是修复。 –