无法验证手柄。使用未解析的标识符' CGLocalPlayer'

时间:2015-10-25 16:30:55

标签: swift swift2

代码位于GameViewController.swift的viewDidLoad函数中。我导入了GameKit。为什么CGLocalPlayer.localPlayer()是未解析的标识符?

class GameViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

var localPlayer = CGLocalPlayer.localPlayer() //error: Use of unresolved identifier 'CGLocalPlayer'

    localPlayer.authenticateHandler = {(viewController : UIViewController!, error : NSError!) -> Void in
        //handle authentication
        if ((viewController) != nil) {
            self.presentViewController(viewController, animated: true, completion: nil)
        }else{

            println((GKLocalPlayer.localPlayer().authenticated))
         }
      }
   }
}

1 个答案:

答案 0 :(得分:0)

使用Swift 2,您应该使用GKLocalPlayer而不是CGLocalPlayer