无法加载iOS 7上的排行榜得分

时间:2013-12-06 19:30:24

标签: ios objective-c ios7 game-center

我有一个功能可以从我的iOS游戏的排行榜中加载最高分,它在iOS 6中运行但在iOS 7中不再有效。我使用的功能如下:

- (void) retrieveGlobalHighScore {
if(userAuthenticated == true) {
    //NSLog(@"Attempting to retrieve global high score...");
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
    if (leaderboardRequest != nil) {
        leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
        leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
        leaderboardRequest.range = NSMakeRange(1,1);
        [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
            if (error != nil) {
                // handle the error. if (scores != nil)
                NSLog(@"ERROR: Issue loading global high score.");
                NSLog(@"Unresolved error %@", error);
            }
            if (scores != nil){
                // process the score information.
                globalHighScoreReturn = ((GKScore*)[scores objectAtIndex:0]).value;
            }
        }];
    }
} else {
    //NSLog(@"User is not authenticated. Global high score not loaded.");
  }
}

我现在收到以下错误,无法弄清楚如何修复它:

Error Domain=GKErrorDomain Code=17 
"The requested operations could not be completed because one or more parameters are invalid." 

UserInfo=0xf539250 {GKServerStatusCode=5053, NSUnderlyingError=0xf538670 "The operation couldn’t be completed. 

status = 5053, asking for legacy aggregate leaderboard on a game with no legacy aggregate leaderboard", NSLocalizedDescription=The requested operations could not be completed because one or more parameters are invalid.}

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:2)

这是我必须添加来解决问题的方法(iOS 7):

        leaderboardRequest.identifier = @"my_leaderboardID";

答案 1 :(得分:1)

我发现了这个问题。在iOS 6中,不需要设置leaderboardRequest.category,并且自动选择了默认排行榜(我只使用1)。在iOS 7中,必须指定类别。指定标识符也可以,但我支持iOS 6和7。