[swift] Swift - How to convert String to Double

On SWIFT 3, you can use:

if let myDouble = NumberFormatter().number(from: yourString)?.doubleValue {
   print("My double: \(myDouble)")
}

Note: - If a string contains any characters other than numerical digits or locale-appropriate group or decimal separators, parsing will fail. - Any leading or trailing space separator characters in a string are ignored. For example, the strings “ 5”, “5 ”, and “5” all produce the number 5.

Taken from the documentation: https://developer.apple.com/reference/foundation/numberformatter/1408845-number