Swift : Convert (cast) String to Double
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 :
See also : Swift : Convert (cast) Int to 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.
Advertisement
Tutorials
+18k Golang : How to remove certain lines from a file
+8.4k Golang : Another camera capture GUI application with GTK and OpenCV
+21.9k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+28.5k Golang : Detect (OS) Operating System
+8.6k Golang : Heap sort example
+6.8k Golang : Levenshtein distance example
+15.3k Golang : How to convert(cast) IP address to string?
+14.1k Golang : How to shuffle elements in array or slice?
+13.4k Generate salted password with OpenSSL example
+7.6k Swift : Convert (cast) String to Double
+18.9k Golang : Populate dropdown with html/template example
+18.9k Golang : Check if directory exist and create if does not exist