When confronting the error fatal error:
Can\'t unwrap Optional.None
It is not that easy to trace this. What causes this error?
<
You get this error, because you try to access a optional
variable, which has no value.
Example:
// This String is an optional, which is created as nil.
var optional: String?
var myString = optional! // Error. Optional.None
optional = "Value"
if optional {
var myString = optional! // Safe to unwrap.
}
You can read more about optionals
in the official Swift language guide.