Posting grades for gamecenter leaders

I am creating a game using Quick Xbox 6 beta 6 and am trying to add a high score for my game to the gamecenter leaderboards. I created leaderboards in gamecenter.

So, how can I add my high score, which I saved as NSUserDefault, to my gamecenter leaderboards?

I tried using:

GKScore.reportScore([highScore], withCompletionHandler: nil) 

but he just falls. The initLeaderboard function is deprecated in ios 8, so I'm not sure what to do.

+6
source share
1 answer

First you need to create a GKScore object. Then you set the value gkScore.value. Finally, you report the bill.

 // if player is logged in to GC, then report the score if GKLocalPlayer.localPlayer().authenticated { let gkScore = GKScore(leaderboardIdentifier: "leaderBoardID") gkScore.value = score GKScore.reportScores([gkScore], withCompletionHandler: ( { (error: NSError!) -> Void in if (error != nil) { // handle error println("Error: " + error.localizedDescription); } else { println("Score reported: \(gkScore.value)") } })) } 
+8
source

Source: https://habr.com/ru/post/974446/


All Articles