【发布时间】:2012-02-03 17:21:34
【问题描述】:
所以我将分数发送到 GC 排行榜,我没有收到任何错误,并且分数也发送了,但我仍然看到排行榜中没有列出任何分数!排行榜本身在 Game Center 中列出,只是没有分数。
根据谷歌搜索和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);
}
});
}];
}
【问题讨论】:
标签: iphone objective-c game-center