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
+19.6k Golang : Determine if directory is empty with os.File.Readdir() function
+5.9k Golang : Extract XML attribute data with attr field tag example
+7.5k Golang : Example of how to detect which type of script a word belongs to
+22.4k Golang : untar or extract tar ball archive example
+12.8k Golang : Calculate elapsed years or months since a date
+7.6k Golang : Gomobile init produce "iphoneos" cannot be located error
+7.3k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+9.1k Golang : Terminate-stay-resident or daemonize your program?
+10.1k Golang : Meaning of omitempty in struct's field tag
+5.8k PageSpeed : Clear or flush cache on web server
+9.5k Golang : Turn string or text file into slice example
+9.6k Golang : Check if user agent is a robot or crawler example