0

the following code is used to get current player' score from GameCenter but it does not show any submitted score:

    if GKLocalPlayer.localPlayer().authenticated {
        let gkScore = GKScore(leaderboardIdentifier: "myID")
        
        gkScore.value = score
        GKScore.reportScores([gkScore], withCompletionHandler: ( { (error: NSError!) -> Void in
            if (error != nil) {
                println("Error: " + error.localizedDescription);
            } else {
                println("Score reported: \(gkScore.value)")
            }
        }

Every time app is running error with localizedDescription is displayed but not real score is displayed / reported:

Error: The requested operations could not be completed because one or more parameters are invalid.

Score reported: 0

Any idea how to fix this while testing app on device?

Thanks for any feedback.

Regards

simoasis

Community
  • 1
  • 1
  • Have you defined the leaderboard in iTunes Connect? What is the value of `score`? – Drux Feb 24 '15 at 21:10
  • Yes, Leaderboard is defined in iTunes Connect (Score format type is set to Integer) and saving highscore to GameCenter by using GKScore.reportScores works fine. score is set to 'var score = Int64()' It is not possible to get current highscore out of GameCenter – simoasis Feb 25 '15 at 19:30
  • fixed it with 'let leaderBoardRequest = GKLeaderboard() leaderBoardRequest.identifier = "myID" let localPlayerScore = leaderBoardRequest.localPlayerScore println("current Highscore: \(localPlayerScore.value)")' and loading highscore – simoasis Feb 25 '15 at 19:55

0 Answers0