In Swift 2.x, the .toInt() function .toInt() been removed from String . Instead, Int now has an initializer that takes a String
Int(myString)
In your case, you can use Int(textField.text!) Insted textField.text!.toInt()
Swift 1.x
let myString: String = "256" let myInt: Int? = myString.toInt()
Swift 2.x, 3.x
let myString: String = "256" let myInt: Int? = Int(myString)
Jojodmo Jun 09 '15 at 18:02 2015-06-09 18:02
source share