I'm trying to work out how to cast an Int
into a String
in Swift.
I figure out a workaround, using NSNumber
but I'd love to figure out how to do it all in Swift.
let x : Int = 45
let xNSNumber = x as NSNumber
let xString : String = xNSNumber.stringValue
Best Answer
Converting
Int
toString
:And the other way around - converting
String
toInt
:Or if you're using Swift 2 or 3: