swift - PromiseKit 语法链 swift

标签 swift swift2 promisekit

我试图在 promise 工具包上链接一些 promise,当 promise 类型像这样时我遇到语法问题 Promise<Location> ,只有当 promise 有类型时,我才会收到编译器错误。我刚开始使用 promisekit

Swift.start(host,"","").then{ result -> Void in

    }.then{ obj -> Void in
        println(obj)
        Swift.getCurrent.then{ obj -> Void in
            let payload:Dictionary<String,AnyObject> = obj as! Dictionary<String,AnyObject>
            self.deviceUUID = payload["uuid"] as! String

        }
    }.then { obj -> Location in
        println(obj)
        Swift.getLocation("3333").then{ location in
            self.locationUUID = location.get("uuid")
        }
    }

最佳答案

你不需要在你的 block 中返回:

.then { obj -> Location in
      Swift.getLocation("433434").then{ location in
          self.locationUUID = location.get("uuid")
      }
}

关于swift - PromiseKit 语法链 swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33354282/

相关文章:

ios - 为 UIWebkit 赋予 Value 并更改实例化 ViewController [Swift 4]

swift - Firebase 使用 uid 快速检索电子邮件

ios - Swift 2.0 - 二元运算符 "|"无法应用于两个 UIUserNotificationType 操作数

ios - 无法使用类型的参数列表调用 animateWithDuration

ios - promise 套件 : compose two promises into one

swift - 使用未声明的类型 'URLDataPromise'

ios - 如何使用 UIImagePickerController 设置视频尺寸?

ios - 如何在 Swift 3 中将字符串转换为数组

swift - 无法将类型 'String' 的返回表达式转换为返回类型 '(Int) -> String'

ios - NSDictionary 的 PromiseKit 不可见类型转换