似乎在Swift3中更改了许多语法,我无法找到此货币的解决方案我提到文档并没有替换它。如果有人遇到这个错误,请你点击下面的答案? 我在下面提到的链接可以使用
func getCurrencyFormat(amount: Double) -> NSString
{
let amountFormatter = NumberFormatter()
amountFormatter.numberStyle = NumberFormatter.currencyStyle -- ///ERROR
amountFormatter.locale = NSLocale.system
return amountFormatter.string(from: amount as NSNumber)! as NSString
}
引用链接仅适用于swift2 Struggling with NSNumberFormatter in Swift for currency
答案 0 :(得分:6)
currencyStyle
已更改为currency
更改此
amountFormatter.numberStyle = NumberFormatter.currencyStyle
进入
amountFormatter.numberStyle =.currency