I have the following enum:
enum ExampleEnum {
case one
case two
case three
case four
}
And the following property definition:
var exampleProperty: ExampleEnum!
prior to swift 4.2 I was using the following switch statement:
switch self.exampleProperty {
case .one:
print("case one")
case .two:
print("case two")
case .three:
print("case three")
case .four:
print("case four")
default:
break
}
Since switching to swift 4.2 this switch statement gives me the error:
Enum case 'one' not found in type 'ExampleEnum?'
I find this odd because I have clearly defined the type with an exclamation mark to implicitly unwrap the optional. However it seems not to be doing that. In order to make the error go away I need to perform the switch as follows:
switch self.exampleProperty! {
case .one:
print("case one")
case .two:
print("case two")
case .three:
print("case three")
case .four:
print("case four")
}
What I did above was unwrap the exampleProperty variable again even though the definition is implicitly unwrapped and also remove the default from the switch.
Just wondering why this change in swift 4.2? Is it a change in the switch statement or why is this unwrapping required again. It seems redundant?