1

私はプレーヤーを認証するためにこの機能を持っています.xcode8ベータ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?, Error?) -> Void) に割り当てることはできません?' " この行に

 self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: NSError?) -> Void in

        self.addLastError(error: error)

        if (viewController != nil)

何が起こっているのかわかりません。誰でも私を助けてくれますか?

4

1 に答える 1

2

申し訳ありませんが、答えは次の行を変更するだけの簡単なものでした:

self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: NSError?) -> Void in

self.localPlayer.authenticateHandler = {(viewController: UIViewController?, error: Error?) -> Void in

私の悪い!ごめん!

于 2016-08-18T14:18:43.157 に答える