I'm getting an error
"fatal error: unexpectedly found nil while unwrapping an Optional value".
What should I do?
I have code like this:
var foo: String?
print ("foo = \(foo!)")
And the print statement is crashing with the error "fatal error: unexpectedly found nil while unwrapping an Optional value". What is that, and how do I fix it?
(Note that it's not just print statements that crash. Any time I use foo!
to try to get the value of foo
, I crash.)