转换器Swift 4.2的扩展
extension Float {
var localeCurrency: String {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = .current
return formatter.string(from: self as NSNumber)!
}
}
访问值
let amount = 200.02
print("Amount Saved Value ",String(format:"%.2f", amountSaving. localeCurrency))
对我来说,它的回报是0.00! 对我来说,扩展性完美访问它时返回0.00!为什么?