我试图在 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/