gpt4 book ai didi

ios - 我如何/在哪里使用 NSNumberFormatter?

转载 作者:搜寻专家 更新时间:2023-11-01 05:38:13 32 4
gpt4 key购买 nike

我是编码新手,在查看了一些答案后仍然需要帮助。

在我的代码中:

func labelInformation(){
numLabels.text = newLabel.text
}

当前结果:

228500.23

期望的结果:

228,500.23

我如何/在哪里使用 NSNumberFormatter?

最佳答案

像这样尝试:

let inputValue = 228500.23

let numberFormatter = NSNumberFormatter()

numberFormatter.numberStyle = .CurrencyStyle
numberFormatter.currencySymbol = ""

let outputString = numberFormatter.stringFromNumber(inputValue) ?? "0.00"

print(outputString) // 228,500.23

关于ios - 我如何/在哪里使用 NSNumberFormatter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34362357/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com