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
+7.7k Swift : Convert (cast) String to Double
+12k Golang : Get remaining text such as id or filename after last segment in URL path
+12.8k Golang : Convert IPv4 address to packed 32-bit binary format
+9.6k Golang : Find correlation coefficient example
+10.4k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+9.8k Golang : Sort and reverse sort a slice of integers
+86.9k Golang : How to convert character to ASCII and back
+8.3k Golang : How to check variable or object type during runtime?
+10.2k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+31.4k Golang : How to convert(cast) string to IP address?
+11k Golang : Fix - does not implement sort.Interface (missing Len method)
+9.2k Golang : Apply Histogram Equalization to color images