I\'m new to Swift, how can I convert a String to CGFloat?
I tried:
var fl: CGFloat = str as CGFloat
var fl: CGFloat = (CGFloat)str
var fl: CGFloat = CGFl
Good question. There is not in fact any pure Swift API for converting a string that represents a CGFloat into a CGFloat. The only string-represented number that pure Swift lets you convert to a number is an integer. You'll have to use some other approach from some other library - for example, start with Foundation's NSString or C's (Darwin's) strtod
.