相关疑难解决方法(0)

Swift中的设置和协议

我想初始化一个Set,其中包含与Hashable协议和自定义协议相对应的值.

我试过了 :

protocol CustomProtocol: Hashable {}

let set = Set<CustomProtocol>()
Run Code Online (Sandbox Code Playgroud)

但是Xcode抱怨道:

不支持使用'CustomProtocol'作为符合协议'Hashable'的具体类型

我怎样才能做到这一点?

提前致谢.

ios swift

17
推荐指数
2
解决办法
3411
查看次数

标签 统计

ios ×1

swift ×1