Swift 3无法转换类型'的值(字符串?,错误?) - >无效!”期望参数类型'((String?,Error?) - > Void)!

时间:2016-10-23 19:54:14

标签: swift swift3

我正在使用LayerKit API,一旦我将项目转换为Swift 3,我就会遇到这种奇怪的错误

编写的代码是。

func authenticateLayerWithUserID(userID: String, completion: @escaping ((_ success: Bool, _ error: NSError?) -> Void)) {
    if let layerClient = layerClient {
        if layerClient.authenticatedUserID != nil {
            print("Layer Authenticated as User \(layerClient.authenticatedUserID)")
            completion(true, nil)
            return
        }

        // Authenticate with Layer
        // See "Quick Start - Authenticate" for more details
        // https://developer.layer.com/docs/quick-start/ios#authenticate

        /*
         * 1. Request an authentication Nonce from Layer
         */
        layerClient.requestAuthenticationNonceWithCompletion() { (nonce: String?, error: Error?) -> Void! in
            if nonce.isEmpty {
                completion(success: false, error: error)
                return
            }
  

“layerClient.requestAuthenticationNonceWithCompletion”行   抛出错误:“无法转换类型的值'(字符串?,错误?) - >   无效!”预期的参数类型'((String?,Error?) - > Void)!'“

如果我添加括号以匹配错误的语法,则会引发更多错误。我该如何解决这个问题?

0 个答案:

没有答案