How to convert a string to a double

Swift strings don't have a built-in way to convert to a Double, but their NSString counterparts do. To convert between strings and doubles, just do this:

let myString = "556"
let myFloat = (myString as NSString).doubleValue

Sponsored You’re already busy updating your app for Swift 4.2 and iOS 12, so why not let Instabug help you find and fix bugs? Add just two lines of code to your project and receive comprehensive reports with all the feedback you need to ship a world-class app – click here to learn more!