我正在使用Swift并尝试创建一些集合对象。这些集合对象有一个用于保存自定义对象的后备Dictionary。例如,对象的类型可能是Cat,而集合对象的类型可能是Cats。{ get set }
当我实际使用协议作为类型时,例如:或
init(objs: ObjectDictionaryProtocoltypealias所遵循的Hashable<
字典键需要符合Hashable:var dictionary = [Test: String]() // Type 'Test' dies not conform to protocol'Hashable'
var dictionary = [Test: String]() // Works
如何获取纯Swift类实例的地址作为hashValue