Ios4 GK排行榜发布问题
我不确定沙盒是否需要太长时间才能更新,或者我的代码是否有问题 我只是简单地抓取本地球员最后输入的分数,并添加另一个分数,并试图张贴结果 这是我的密码:Ios4 GK排行榜发布问题,ios4,gamekit,Ios4,Gamekit,我不确定沙盒是否需要太长时间才能更新,或者我的代码是否有问题 我只是简单地抓取本地球员最后输入的分数,并添加另一个分数,并试图张贴结果 这是我的密码: - (void) reportScore: (int64_t) score forCategory: (NSString*) category { GKScore *scoreReporter = [[[GKScore alloc]initWithCategory:category] autorelease]; scoreReporter.val
- (void) reportScore: (int64_t) score forCategory: (NSString*) category
{
GKScore *scoreReporter = [[[GKScore alloc]initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
// handle the reporting error
NSLog(@"Error reporting score");
}
}];
}
-(void)postScore:(int64_t)score forCategory:(NSString *)category {
GKLeaderboard *query = [[GKLeaderboard alloc]init];
query.category = category;
if (query != nil)
{
[query loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil){
// Handle the error.
NSLog(@"Error loading scores");
}
if (scores != nil){
// Process the score.
int64_t newScore = query.localPlayerScore.value + score;
[self reportScore:newScore forCategory:category];
}
}];
}
[query release];
}
谢谢你的帮助
编辑:沙盒排行榜有第一个分数,但不会更新后续分数 我这边也有同样的问题。它将在会话中第一次正确提供分数。之后,即使我们在该会话中更新了分数,它也会继续发回相同的分数 您需要检查GK排行榜类的属性。有关您的信息。请参阅下面的代码 GKLeaderboardViewController*leaderController=[[GKLeaderboardViewController alloc]init]
if (leaderboardController != NULL)
{
leaderController.category = self.currentLeaderBoard;
leaderController.timeScope = GKLeaderboardTimeScopeWeek;
leaderController.leaderboardDelegate = self;
[self presentModalViewController: leaderController animated: YES];
}
AND
您还可以在下面的GKLeaderBoard和GKAchieventViewController类中查看apple文档
对于GK排行榜
用于GK实现视频控制器