gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 14:53:15 25 4
gpt4 key购买 nike

我正在尝试从我的路径中获取一个 json。一切似乎都是正确的(假设我来自 Swift 2 并尝试更新到 Swift 4)然而,事情似乎出了问题。

class func getPlayerStatuses(sportName: String) -> Promise<[NSDictionary]> {
let path = "api/sports/player-status/\(sportName)/"
return API.get(path).then { (json: NSDictionary) -> [NSDictionary] in
let playerUpdates: [NSDictionary] = try json.get("player_updates")
return playerUpdates
}
}

我收到以下错误。

Cannot convert value of type '(NSDictionary) throws -> [NSDictionary]' to expected argument type '(_) throws -> _'

有没有人知道为什么我会收到有关类型转换的错误?

最佳答案

返回非 promise 值的方式在PMK 6中改变了(参见 为什么选择 PromiseKit 5/6? 部分)。现在你应该使用 map 而不是 then 来完成这种工作。

关于ios - NSDictionary 的 PromiseKit 不可见类型转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49625481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com