String转数字
Swift
var text: String = "111"
var number: Int? = Int(text)
Swift
let text: String = "111"
var n: Int = (text as NSString).integerValue
数字转String
Swift
let number: Float = 123.5
var string: String = "\(number)"
Swift
var number: Float = 123.5
var string = String(number)
数字之间互转
Swift
var doubleNumber = 1.8
var intNumber = 0
intNumber = Int(doubleNumber)