我想知道以下代码有什么问题?
import Foundation
enum SliderType: Int {
case analog = 1, discrete, highLow
}
protocol DataEntry: class, Hashable {
var hashValue: Int { get set } // hashable protocol requires this
var idx: Int { get set }
var category: String { get set }
var sliderType: SliderType { get set }
var sliderTitle: String { get set }
var sliderCurrentValue: Float { get set }
var sliderMinValue: Float { get set }
var sliderMaxValue: Float { get set }
}
func ==(lhs: DataEntry, rhs: DataEntry) -> Bool {
return lhs.idx == rhs.idx
}
从这个屏幕截图中可以看出,我不断收到错误消息Protocol 'DataEntry' can only be used as a generic constraint because it has Self or associated type requirements
有人知道这里可能出了什么问题吗?你如何实现一个 Hashable 协议到一个协议?