I would like to get a UITextField
input as an Integer? I tried Int(UITextField Input)
, but it throws an error. I also tried making a variable with the same value, but it did not work.
if you define like this -> @IBOutlet weak var textField: UITextField!
you can use (textField.text! as NSString).intValue
or Int(textField.text!)
. You must use exclamation mark.
But you define like this ->
let textField = UITextField() textField.text = "007"
you don't need use exclamation mark
EDIT:
(textField.text! as NSString).intValue
is INT32 Format, you can do this for normal Int format ->Int((textField.text! as NSString).intValue)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments