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
in Swift 3.0
if let n = NumberFormatter().number(from: string) { let f = CGFloat(n) }
or this if you are sure that string meets all requirements
let n = CGFloat(NumberFormatter().number(from: string)!)