【发布时间】:2015-10-26 19:44:25
【问题描述】:
我正在尝试在 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")
}
}
【问题讨论】:
-
请贴出你得到的编译错误。
-
另外你的第二个块应该返回一个 Location 对象。它不返回任何东西。
-
AppDelegate.swift:43:15: Cannot invoke 'then' with an argument list of type '((Location) -> Location)',如何返回位置,语法是什么
标签: swift swift2 promisekit