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
This is kind of a work around, but you can cast it as an NSString, then get the float value, then initialize a CGFloat from that value. Example:
let str = "1.02345332" let foo = CGFloat((str as NSString).floatValue)