I'm watching the Stanford Swift lecturers on ItunesU and have some trouble in understanding.
The lecturer is typecasting a String to a Double at one point. He did it as follows:
return NSNumberFormatter().numberFromString(display.text!)!.doubleValue
display.text is a UILabel Anyhow, when I'm doing it like this my app crashes and I get the following error:
fatal error: unexpectedly found nil while unwrapping an Optional value
When I typecast the String like this:
(display.text! as NSString).doubleValue
it works fine.
I know there must be an optional var anywhere but I'm not that into it to say what is wrong at this point.