iOS游戏中心沙箱:排行榜显示“没有得分”
问题描述:
因此,我将分数发送给GC排行榜,我没有收到任何错误,而且分数正常发送,但我仍然看不到排行榜中列出的分数!排行榜本身在Game Center中列出,没有得分。iOS游戏中心沙箱:排行榜显示“没有得分”
根据Google搜索和question on here这可以通过尝试记录多个帐户的分数来解决。我现在已经在模拟器(iOS5)和我的iPhone上尝试了三个不同的帐户;提交评分时,他们都没有显示任何错误。
发送比分的代码是在这里:
- (void)reportScore:(NSString *)identifier score:(int)rawScore {
GKScore *score = [[[GKScore alloc] initWithCategory:identifier] autorelease];
score.value = rawScore;
[scoresToReport addObject:score];
[self save]; // Save here even though we save again in didEnterBackground, just in case of crash...
if (!gameCenterAvailable || !userAuthenticated) return;
[self sendScore:score];
}
- (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);
}
});
}];
}
答
它突然开始工作(不更改任何代码,甚至是重新编译)。我认为排行榜需要一段时间才会真正出现,对我来说大约需要18个小时。
在这段时间内提交的比分仍然会记录下来,他们只是不会立即可见。
答
我从来没有得到的分数添加到沙箱要么,但这里是我实现的代码,它目前工作正常版本的应用程序商店:
GKScore * score = [[[GKScore alloc] initWithCategory:@"com.example.appname.scoreboardname"] autorelease];
score.value = [[NSUserDefaults standardUserDefaults] integerForKey:@"NEWSCORE"];
[score reportScoreWithCompletionHandler:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (error == NULL) {
NSLog(@"Score Sent");
} else {
NSLog(@"Score Failed");
}
});
}];
只要确保你的GKScore.value的类型是int64_t