Learn Common Swift collection casting or type conversion
Collection of Common Swift Casting or Type Conversion String to Double var a = "1.5" var b = (a as NSString).doubleValue ...
https://www.czetsuyatech.com/2015/01/xcode-swift-collections.html
Collection of Common Swift Casting or Type Conversion
String to Double
var a = "1.5"
var b = (a as NSString).doubleValue
Double to String
var a : Double = 1.5
var b = String(format:"%f", a)
Double to Int
var a : Double = 1.5
var b = Double(a)
String to Float
var a = "1.5"
var b = (a as NSString).floatValue
String to Float
var a = "1.5"
var b = (a as NSString).intValue
String to Double
var a = "1.5"
var b = (a as NSString).doubleValue
Double to String
var a : Double = 1.5
var b = String(format:"%f", a)
Double to Int
var a : Double = 1.5
var b = Double(a)
String to Float
var a = "1.5"
var b = (a as NSString).floatValue
String to Float
var a = "1.5"
var b = (a as NSString).intValue
Post a Comment