0
votes

I am able to display a single leaderboard. I created a leaderboard set in iTunes Connect and I am not sure how to save the scores into different leaderboards in a leaderboard set. I am also not sure how to display all of the leaderboard in my leaderboard set in the Game Center's view controller.

 func saveHighScore(highscore:Int){
            if GKLocalPlayer.localPlayer().authenticated {            
                let scoreReporter = GKScore(leaderboardIdentifier: "easymodehighscores")

                scoreReporter.value = Int64(highScore)

                let scoreArray : [GKScore] = [scoreReporter]

                GKScore.reportScores(scoreArray, withCompletionHandler: nil)

            }
        }

This is my code for saving a high score into one of the leaderboards.

    let viewController = self.view.window?.rootViewController
    let gameCenterVC = GKGameCenterViewController()
    gameCenterVC.gameCenterDelegate = self
    viewController?.presentViewController(gameCenterVC, animated: true, completion: nil)

This is my code for presenting the Game Center view controller.

1
Ok, I've noticed that the leaderboard set automatically gets displayed. But there is one issue: for some reason I see 2 leaderboards with the same name when I open the leaderboard set in the game center view controller. I checked itunes connect and I'm sure that I don't have two leaderboards with the same name.Pirlo Lochisomo
I deleted all of my leaderboards and created them again, now there aren't 2 leaderboards with the same namesPirlo Lochisomo

1 Answers

0
votes

My solution was to use switch to switch between the different leaderboards, and just use the leaderboard identifier to save the high scores to. Game center viewcontroller also displays all the leaderboards of this app automatically if you configured everything in iTunes Connect correctly.