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

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -