【发布时间】:2016-12-05 08:20:07
【问题描述】:
我有一个枚举:
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协议。 nshipster.com/swift-comparison-protocols