2015-01-15 5 views
-1

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

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

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!") 

     } 

    }) 
    } 
} 

} 

Цель хак аутентификации 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 

ответ

0

Формат лидеров Id изменился.

Вместо "come.company.id"

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

"Идентификатор"

 Смежные вопросы

  • Нет связанных вопросов^_^