In my iOS9 project, I have a total of 8 leaderboards associated with Game Center. I can load the list of all leaderboards (which is GREAT for another part in my app); however, I would also like to be able to load one particular leaderboard. Here is the code I am using:
@IBAction func showLeaderboard() {
if savedSettings["difficulty"] == 0 {
print("Easy")
if savedSettings["gameLanguage"] == 0 {
leaderboardID = "Colorific_English_High_Scores"
print("english")
} else if savedSettings["gameLanguage"] == 1 {
leaderboardID = "Colorific_Spanish_High_Scores"
} else {
leaderboardID = "Colorific_French_High_Scores"
}
} else {
if savedSettings["gameLanguage"] == 0 {
leaderboardID = "Colorific_English_High_Scores_Hard"
} else if savedSettings["gameLanguage"] == 1 {
leaderboardID = "Colorific_Spanish_High_Scores_Hard"
} else {
leaderboardID = "Colorific_French_High_Scores_Hard"
}
}
let gcVC: GKGameCenterViewController = GKGameCenterViewController()
gcVC.leaderboardIdentifier = leaderboardID
gcVC.gameCenterDelegate = self
gcVC.viewState = GKGameCenterViewControllerState.Leaderboards
self.presentViewController(gcVC, animated: true, completion: nil)
}
Unfortunately, updating the leaderboardIdentifier seems to have no effect. The list of all leaderboards always seems to show up. In fact... even changing the viewState to GKGameCenterViewControllerState.Achievements seems to have no effect, either! It always goes to that list of leaderboards :(
Thank you in advance for all of your help! :)