我想把-33.861382,151.210316,226.76转换为字符串。我试图键入cast它,但是unscucessful。
如何将float值转换为String?
如何将float值转换为String?
如果你想要更多的控制如何转换你可以使用stringWithFormat在NSString或NSNumberFormatter
let f = -33.861382 let s = NSString(format: "%.2f",f) let nf = NSNumberFormatter() nf.numberStyle = .DecimalStyle // Configure the number formatter to your liking let s2 = nf.stringFromNumber(f)