【问题标题】:Swift3: Type numberformatter has no member 'currency style', swift3Swift3:类型 numberformatter 没有成员“货币样式”,swift3
【发布时间】:2016-09-22 06:10:57
【问题描述】:

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

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

【问题讨论】:

    标签: ios swift swift3 nsnumberformatter


    【解决方案1】:

    currencyStyle改成currency

    改一下

    amountFormatter.numberStyle = NumberFormatter.currencyStyle
    

    进入

    amountFormatter.numberStyle =.currency
    

    查看苹果API参考Documents

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 2013-10-18
      • 2018-01-15
      • 2015-12-25
      • 2013-09-21
      相关资源
      最近更新 更多