swift - How do I get a UITextField input as an Integer -
i uitextfield
input integer? tried int(uitextfield input)
, throws error. tried making variable same value, did not work.
if define -> @iboutlet weak var textfield: uitextfield!
can use (textfield.text! nsstring).intvalue
or int(textfield.text!)
. must use exclamation mark.
but define ->
let textfield = uitextfield() textfield.text = "007"
you don't need use exclamation mark
edit:
(textfield.text! nsstring).intvalue
int32 format, can normal int format ->int((textfield.text! nsstring).intvalue)
Comments
Post a Comment