【发布时间】:2015-10-17 17:14:26
【问题描述】:
我想用对应于 Hashable 协议和自定义协议的值初始化一个 Set。
我试过了:
protocol CustomProtocol: Hashable {}
let set = Set<CustomProtocol>()
但是 Xcode 抱怨:
使用“CustomProtocol”作为符合协议的具体类型 不支持“可哈希”
我怎样才能做到这一点?
提前致谢。
【问题讨论】:
-
中的对象已经被要求符合Hashable。
-
如果 CustomProtocol 不符合 Hashable,Xcode 会抱怨 CustomProtocol 不符合它。看来我错过了什么。