我有这个功能来验证播放器,它工作得很好,直到xcode8 beta 6:
func authenticateLocalPlayer()
{
print(#function)
// WillSignIn
self.delegate?.willSignIn?()
// The player authenticates in an asynchronous way, so we need a notification to inform when the authentication was completed successfully
// If the local player is already connected, return and notificate
if GameKitHelper.sharedGameKitHelper.localPlayer.isAuthenticated {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: Constants.LocalPlayerIsAuthenticated), object: nil)
return
}
// Calling the authentication view controller
self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: NSError?) -> Void in
self.addLastError(error: error)
if (viewController != nil)
{
self.addAuthenticationViewController(authenticationViewController: viewController!)
}
// If the localPlayer authenticated successfully notificate
else if (self.localPlayer.isAuthenticated == true)
{
self.gameCenterConnected = true
print("Local player ID: \(self.localPlayer.playerID)")
print("Local player Alias: \(self.localPlayer.alias)")
NotificationCenter.default.post(name: NSNotification.Name(rawValue: Constants.LocalPlayerIsAuthenticated), object: nil)
}
// If the localPlayer failed to authenticate
else
{
self.gameCenterConnected = false
}
if (error != nil)
{
// Handle error here
}
}
}
现在我得到这个错误“无法分配类型的值'(UIViewController?,NSError?) - > Void'要输入'((UIViewController?,错误?) - > Void)?' “ 在这一行
self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: NSError?) -> Void in
self.addLastError(error: error)
if (viewController != nil)
我不知道发生了什么事。 有人可以帮我吗?
答案 0 :(得分:2)
self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: NSError?) -> Void in
到
self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: Error?) -> Void in
我的坏!遗憾!