刚刚完成我的第一个iOS游戏(主要是)。它准备就绪,只需要在游戏中心链接。然而,事实证明这是令人讨厌的。我的应用程序全部在iTunes Connect上注册,所有Game Center代码都直接从Apple获取。那为什么没有这个工作?
首先:身份验证始终失败;
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“播放器未签署消息”
第二:这个
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];
}
表示'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
我从根本上做错了什么?感谢任何可以提供帮助的人。
答案 0 :(得分:3)
尝试使用您的测试用户帐户在Game Center应用程序中注销/ 请检查此答案:https://stackoverflow.com/a/4420457/89364