print(String(format: "%d", locale: Locale.current, 33600))
//prints 33.600
print(String(format: "%d", locale: Locale.current, 3360))
//prints 3360 without thousands separator
使用NumberFormatter也是同样的问题。
在美国,千位分隔符是逗号,下面的代码:
print(String(format: "%d", locale: Locale.current, 33600))
print(String(format: "%d", locale: Locale.current, 3360))
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
print(formatter.string(from: 33600)!)
print(formatter.string(from: 3360)!)
输出:
33,600
3,360
33,600
3,360
所以它能正常工作