Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reporting score to gamecenter for ios7

According to https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/LeaderBoards/LeaderBoards.html

Reporting score to gamecenter in ios7 should be done using

[GKLeaderboard reportScores:scores withCompletionHandler:^(NSError *error) {
//Do something interesting here.
}];

However, I could not find any reference to this method in GKLeaderboard.

The method does not exist here: https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLeaderboard_Ref/Reference/Reference.html

GKLeaderboard.h does not contain a reportScores method also.

The former way of reporting score using GKScore's reportScoreWithCompletionHandler method had been deprecated so I am reluctant to use that.

Does anyone know whats the correct way to report score to gamecenter in ios7?

like image 560
Cymric Avatar asked Oct 16 '13 03:10

Cymric


1 Answers

I can confirm that the reportScores:withCompletionHandler: method does work; I'm using it in one of my apps. It's located in the header file GKScore.h. This is how I'm using it:

- (void) reportHighScore:(NSInteger) highScore {
    if ([GKLocalPlayer localPlayer].isAuthenticated) {
        GKScore* score = [[GKScore alloc] initWithLeaderboardIdentifier:MY_LEADERBOARD_ID];
        score.value = highScore;
        [GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
            if (error) {
                // handle error
            }
        }];
    }
}
like image 160
Greg Avatar answered Oct 02 '22 11:10

Greg