I have the following code:
var displayValue: Double{
get{
println("display.text =(display.text!)")
return NSNumberFormatter().numberFromString(display.text!)!.doubleValue
}
set{
display.text = "(newValue)"
userIsInTheMiddleOfTypingANumber = false;
}
}
It works fine in the simulator. but when I try it on phone it crashes.
here is the console:
digit= 3
display.text =3
operandStack =[3.0]
digit= 2
display.text =2
operandStack =[3.0, 2.0]
display.text =6.0
fatal error: unexpectedly found nil while unwrapping an Optional value
This line:
NSNumberFormatter().numberFromString(display.text!)!
is returning nil which causing the app to crash cause it couldn't unwrap the optional. I really don't know what's wrong. I'm following some tutorials in iTunes U.
any help would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…