Swift3:类型numberformatter没有成员'货币样式',swift3

时间:2016-09-22 06:10:57

标签: ios swift swift3 nsnumberformatter

似乎在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
}

enter image description here

引用链接仅适用于swift2 Struggling with NSNumberFormatter in Swift for currency

1 个答案:

答案 0 :(得分:6)

currencyStyle已更改为currency

更改此

amountFormatter.numberStyle = NumberFormatter.currencyStyle

进入

amountFormatter.numberStyle =.currency

here

请参阅Apple API参考enter image description here