2012-09-24 86 views
1

刚刚完成我的第一个iOS游戏(大部分)。它的一切准备就绪,只需要在Game Center中链接。然而,这证明是...烦人的。我的应用程序全部在iTunes Connect上注册,所有Game Center代码均直接从Apple获取。那么为什么NONE这个工作?游戏中心的问题

第一:认证总是失败;

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; 

localPlayer.authenticateHandler = ^(UIViewController *loginVC, NSError *error) { 
    if ([GKLocalPlayer localPlayer].authenticated) { 
     // authentication successful 
    } 
    else if (loginVC) { 
     // player not logged in yet, present the vc 
     [self presentViewController:loginVC animated:YES completion:nil]; 
    } 
    else { 
     // authentication failed 
    } 
}; 

有了错误“的请求的操作已被取消”

其必然结果是,试图在未来呈现游戏中心VC yeilds一个“球员没有在消息签署”

二:这个

GKScore *score = [[GKScore alloc] init]; 
if (score) { 
    score.value = self->selectedScore; 
    NSArray* scoreArray = [[NSArray alloc]initWithObjects:score, nil]; 
    //score.category = @"High Scores"; 

    UIActivityViewController *avc = [[UIActivityViewController alloc] 
            initWithActivityItems:scoreArray applicationActivities:nil]; 
    avc.completionHandler = ^(NSString *activityType, BOOL completed) { 
     if (completed) 
      [self dismissViewControllerAnimated:YES completion:nil]; 
    }; 

    if (avc) 
     [self presentViewController:avc animated:YES completion:nil]; 
} 

yeilds一个'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'

我从根本上做错了什么?感谢任何可以提供任何帮助的人。

+0

您在第一个代码块中似乎有复制错误,请问您能纠正它吗? – Kevin

+0

抱歉。固定!感谢提高 –

回答

3

尝试使用您的测试用户帐户在Game Center应用程序中注销/注销。
检查答案:https://stackoverflow.com/a/4420457/89364

+0

雅,奇怪的是,工作。更奇怪的是为什么我从来没有想过这样做。尽管如此,感谢您花时间阅读/回复!不胜感激! –