objective-cgamekitgame-center-leaderboard

Open single leaderboard


I have a problem with the GameKit, I already have two leaderboards integrated into my app. When I open the leaderboard always appears just one leaderboard, but I have 2 I want to open the second leaderboard, how can I do that?

Here is my code to open the main leaderboard:

- (void) openLeaderboard {
    GKLeaderboardViewController *leaderboardController =[[GKLeaderboardViewController alloc]init];
    if (leaderboardController != nil)
    {
        leaderboardController.leaderboardDelegate = self;
        [self presentViewController: leaderboardController animated: YES completion:nil];
    }
}

Thanks in advance


Solution

  • GKLeaderboardViewController is deprecated in iOS 7.0. However, first things first;

    leaderboardController.leaderboardIdentifier = @"YOUR_SECOND_LEADERBOARDS_ID";
    

    It says "Use GKGameCenterViewController instead", hence;

    (I didn't try the code below, but it seemed as a reasonable update. Please let me know whether that's working or not).

    GKGameCenterViewController* gcViewController = [[GKGameCenterViewController alloc]init];
    gcViewController.gameCenterDelegate = self;
    gcViewController.viewState = GKGameCenterViewControllerStateLeaderboards;