Xcode : 编译器错误 Dictionary <key, value > is not conversionable to hashable
Xcode : Compiler error Dictionary <key, value > is not convertible to hashable
我在 Xcode 中使用 Swift 制作了一个应用程序,尽管代码中似乎没有错误,但构建还是失败了。但是,我收到此错误:
Compiler error Dictionary <>key, value <> is not convertible to hashable.
我该如何解决这个问题?我已经搜索过这个但没有找到任何帮助。
目标C:
NSDictionary
密钥必须符合 NSCopying
协议。如果键是自定义对象,请添加代码以使其符合要求。
Swift:
字典的所有键都必须与其键类型 (Key) 兼容。
来自 The Swift Programming Language - Dictionary Type:
The key type of a dictionary must conform to the Swift standard library Hashable protocol.
来自编码浏览器博客:
The built in Swift types like Int, Double, and String are hashable.
我在 Xcode 中使用 Swift 制作了一个应用程序,尽管代码中似乎没有错误,但构建还是失败了。但是,我收到此错误:
Compiler error Dictionary <>key, value <> is not convertible to hashable.
我该如何解决这个问题?我已经搜索过这个但没有找到任何帮助。
目标C:
NSDictionary
密钥必须符合 NSCopying
协议。如果键是自定义对象,请添加代码以使其符合要求。
Swift:
字典的所有键都必须与其键类型 (Key) 兼容。
来自 The Swift Programming Language - Dictionary Type:
The key type of a dictionary must conform to the Swift standard library Hashable protocol.
来自编码浏览器博客:
The built in Swift types like Int, Double, and String are hashable.