Simple types / Strings

//to Int
let strNumber = "42"
let number: Int = Int(strNumber)!

//to Double and Float
//the first method
let strPi = "3.14"
let pi: Float = Float(atof(strPi))

//the second method
let strExp = "2.71828"
let exp = (strExp as NSString).doubleValue

//the third method
let strHalf = "0,5"
let formatter = NumberFormatter()
formatter.decimalSeparator = ","
let half = formatter.number(from: strHalf)!.doubleValue

print("number is \(number)")
print("pi is \(pi)")
print("exp is \(exp)")
print("half is \(half)")