Reputation: 7
I am using regular Objective-C in Xcode.
I created a Game Center leaderboard on iTunes Connect. When my app is opened, it asks for a login the first time, then checks to see if you're already signed in or not every other time after that.
I also have a high score saved as a userDefault integer. I just don't know how to take my int "HighScore", create a public leader board, and then put everyone's HighScore on to the leaderboard. How can I accomplish this?
I cannot find any tutorials on making leaderboards and Apple's developer website just doesn't help.
Upvotes: 0
Views: 333
Reputation: 616
This is working for me:
//Define UserDefaults
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
//Create Score with leaderboardIdentifier
GKScore *newScore = [[GKScore alloc] initWithLeaderboardIdentifier:@"leaderboardIdentifier"];
newScore.value = [userDefaults integerForKey:@"highScore"];
//Submit Score
[GKScore reportScores:@[newScore] withCompletionHandler:nil];
Upvotes: 2