I'm extremely new to Swift, and I'm trying to build a simple calculator to test the waters. I have a UILabel with name 'display', and I want to store its value as an int in a variable called 'numA'. However, when I did that, the variable numA gets the value nil.
I discovered why this happened, because when I simply print the display text in the console:
println("(display.text!)")
I get this: " 6" instead of "6". Notice the additional space appended at the beginning. This is why I cannot do this:
var numA = display.text!.toInt()
What am I doing wrong?
Thanks
Aucun commentaire:
Enregistrer un commentaire