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
+6.2k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+25.7k Golang : missing Mercurial command
+5.4k Golang : If else example and common mistake
+11.2k CodeIgniter : How to check if a session exist in PHP?
+5.3k Golang : How to deal with configuration data?
+9.4k Golang : Qt Yes No and Quit message box example
+7k Golang : Levenshtein distance example
+9.1k Golang : Simple histogram example
+21.6k Golang : GORM create record or insert new record into database example
+11.6k Golang : Display a text file line by line with line number example
+32.4k Golang : Copy directory - including sub-directories and files
+8.8k Yum Error: no such table: packages