Таблица лидеров Swift Game Center не показывает результатов

Привет, у меня проблемы с попаданием очков в мою таблицу лидеров в Swift. В коннекте все хорошо. Раньше я успешно составлял таблицу лидеров, но в задаче c. Мне интересно, есть ли быстрая ошибка, которую мне не хватает. Я не получаю никаких ошибок при отправке новой оценки. Я создал класс gamecenterhelper, через который я делаю весь игровой центр, как показано ниже:

Спасибо!! и да, все мои идентификаторы верны

Swift GameCenterHelper

import Foundation
import GameKit

class GameCenterHelperSwift: NSObject, GKGameCenterControllerDelegate {
var leaderboardIdentifier: String? = nil
var gameCenterEnabled: Bool = false
var myViewController: UIViewController!


init(VC:UIViewController){
    myViewController = VC
}


func openLeaderBoard(id: String) {
    var gameCenter = GKGameCenterViewController()
    gameCenter.gameCenterDelegate = self
    gameCenter.leaderboardIdentifier = id
    self.myViewController.presentViewController(gameCenter, animated: true, completion: nil)
}

func authenticateLocalPlayer()
{
    var localPlayer = getLocalPlayer() // see GKLocalPlayerHack.h
    localPlayer.authenticateHandler =
        { (viewController : UIViewController!, error : NSError!) -> Void in
            if viewController != nil
            {
                self.myViewController.presentViewController(viewController, animated:true, completion: nil)
            }
            else
            {
                if localPlayer.authenticated
                {
                    self.gameCenterEnabled = true
                    localPlayer.loadDefaultLeaderboardIdentifierWithCompletionHandler
                        { (leaderboardIdentifier, error) -> Void in
                            if error != nil
                            {
                                print("error")
                            }
                            else
                            {
                                self.leaderboardIdentifier = leaderboardIdentifier
                                println("\(self.leaderboardIdentifier)") 
                            }
                    }
                }
                else
                {
                    println("not able to authenticate fail")
                    self.gameCenterEnabled = false

                    if (error != nil)
                    {
                        println("\(error.description)")
                    }
                    else
                    {
                        println(    "error is nil")
                    }
                }
            }
    }

}

func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController!) {
    gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
}


func saveHighscore(id: String, Score: Float){
    if GKLocalPlayer.localPlayer().authenticated {
    var scoreReporter = GKScore(leaderboardIdentifier: id)
    scoreReporter.value = Int64(Score);

    var scores = [scoreReporter]

    GKScore.reportScores(scores, withCompletionHandler: { (error : NSError!) -> Void in
        println("reporting")
        if error != nil {
            println("error")
            println("\(error.localizedDescription)")
        }else{
            println("nice score!")

        }

    })
    }
}

}

Взлом аутентификации Objective C (отлично работает, добро пожаловать)

//  GKLocalPlayerHack.h
// Issue with GameKit and Swift
// http://stackoverflow.com/questions/24045244/game-center-not-authenticating-using-   swift

#import <GameKit/GameKit.h>

@interface GKLocalPlayerHack : NSObject

GKLocalPlayer *getLocalPlayer(void);

@end

// GKLocalPlayerHack.m
// Issue with GameKit and Swift
// http://stackoverflow.com/questions/24045244/game-center-not-authenticating-using-swift

#import "GKLocalPlayerHack.h"

@implementation GKLocalPlayerHack

GKLocalPlayer *getLocalPlayer(void)
{
return [GKLocalPlayer localPlayer];
}

@end

person T Neate    schedule 15.01.2015    source источник


Ответы (1)


Изменился формат идентификатора таблицы лидеров.

Вместо "company.id"

теперь это просто

"id"

person T Neate    schedule 15.01.2015