0

I have an enum:

enum StoresSortType {
    case address, number, lastInspectionDate, distance(CLLocation)
}

I want to check only case without parameters, like that:

 let type = StoresSortType.address
 if lastSorting.type == type {
     //logic here
 }

But I have an error: path_to_file.swift:197:69: Binary operator '==' cannot be applied to two 'StoresSortType' operands

How I can do that with ignoring of CLLocation parameter in last case?

Artem Novichkov
  • 2,356
  • 2
  • 24
  • 34
  • You need to make the `StoreSortType` confirm to `Equatable` protocol. http://nshipster.com/swift-comparison-protocols/ – Sachin Vas Dec 05 '16 at 08:23

1 Answers1

0

You could use a switch statement

switch( lastSorting )
{
 case .distance:
 break
 default:
 break
}
Radu Diță
  • 13,476
  • 2
  • 30
  • 34