我是编码新手,在查看了一些答案后仍然需要帮助。
在我的代码中:
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/