gpt4 book ai didi

xcode - 无法使用 Dictionary 类型的参数列表调用

转载 作者:行者123 更新时间:2023-11-30 14:06:00 25 4
gpt4 key购买 nike

我有一个具有以下签名的函数:

static func dictionaryToJSON<K : ToJSON,V : ToJSON> ( dictionary : Dictionary<K,V>) -> JValue

可以找到here

当我尝试调用此函数时,收到错误 Cannot invoke 'dictionaryToJSON' with an argument list of type '(Dictionary<Domain, Account>)' 。调用如下:

let accounts : JValue = Aeson.dictionaryToJSON( self.accounts)

self.accounts类型为Dictionary<Domain,Account> ,域和帐户都实现协议(protocol) ToJSON 。有什么原因导致这不进行类型检查吗?这是针对 Swift 2 (XCode 7 beta 6) 的,所以也许存在编译器错误?

最佳答案

看起来我注释掉了 ToJSON 的 Domain 实现来调试并忘记了。现在正在工作。

关于xcode - 无法使用 Dictionary<Generic, Generic> 类型的参数列表调用 <function>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32401125/

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