0
我有一個枚舉:檢查枚舉情況下
enum StoresSortType {
case address, number, lastInspectionDate, distance(CLLocation)
}
我想不帶參數只檢查的情況下,這樣的:
let type = StoresSortType.address
if lastSorting.type == type {
//logic here
}
但我有一個錯誤:path_to_file.swift:197:69: Binary operator '==' cannot be applied to two 'StoresSortType' operands
在最後一種情況下,我怎麼能忽略CLLocation
參數?
你需要做的'StoreSortType'確認爲'Equatable'協議。 http://nshipster.com/swift-comparison-protocols/ –