Convert a string into an int

Viewed 131790

I'm having trouble converting a string into an integer. I googled it but all I can find is how to convert an int into a string. Does anyone know how to do it the other way around? Thanks.

11 Answers

To convert an String number to an Int, you should do this:

let stringNumber = "5"
let number = Int(stringNumber)
Related