San*_*nju 1 nsnumberformatter ios swift swift3
似乎是在Swift3中更改了许多语法,我无法找到这个currencyStyle的解决方案我提到的文档没有替换这个.如果有人遇到这个错误,请你点击下面的答案?我在下面提到的链接可以使用
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
}
Run Code Online (Sandbox Code Playgroud)
引用链接仅适用于swift2 在Swift中使用NSNumberFormatter进行货币争夺
currencyStyle 变成了 currency
改变这一点
amountFormatter.numberStyle = NumberFormatter.currencyStyle
Run Code Online (Sandbox Code Playgroud)
成
amountFormatter.numberStyle =.currency
Run Code Online (Sandbox Code Playgroud)
请参阅Apple APIreference 文档