Swift : Convert (cast) String to Float
Problem :
You have a string value and you need to convert the string into type float.
Solution :
Use NSString for direct casting from type string to float. For example :
var StrToFloat = (SomeInputString.text as NSString).floatValue
See also : Swift : Convert (cast) String to Integer
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
+8.9k Android Studio : Indicate progression with ProgressBar example
+19.5k Golang : Measure http.Get() execution time
+19.5k Golang : Archive directory with tar and gzip
+16.7k Golang : Get input from keyboard
+9.1k Golang : Timeout example
+12.6k Golang : Convert int(year) to time.Time type
+16.7k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+11.1k Golang : How to flush a channel before the end of program?
+8.7k Golang : Find network service name from given port and protocol
+7.7k Swift : Convert (cast) String to Float
+9.5k Random number generation with crypto/rand in Go