转换器 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!在我看来,Extension Perfect 访问时返回 0.00!为什么?