Swift : Convert (cast) String to Double

Tags : casting swift double string

Helping out a colleague to solve this simple task of converting string value to double today. Putting down this solution here and hope it can be useful as tutorial for other Swift programmers.

Problem :

How to convert (cast) String to Double in Swift programming language ?

Solution :

 var str = "123.456"
 var doubleNSString = NSString(string: str)
 var toDouble = doubleNSString.doubleValue

Reference :

Apple Documentation on NSString doubleValue

  See also : Swift : Convert (cast) Int to String ?

Tags : casting swift double string

By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.

Helping out