I am having problems using strings in switch statements in Swift.
I have a dictionary called opts
which is declared as
I had this same error message inside prepareForSegue()
, which I imagine is fairly common. The error message is somewhat opaque but the answers here got me on the right track. If anyone encounters this, you don't need any typecasting, just a conditional unwrap around the switch statement:-
if let segueID = segue.identifier {
switch segueID {
case "MySegueIdentifier":
// prepare for this segue
default:
break
}
}