代码位于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))
}
}
}
}
答案 0 :(得分:0)
使用Swift 2,您应该使用GKLocalPlayer
而不是CGLocalPlayer
。