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

Popular posts from this blog

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -