我的英语不足以搜索问题。所以,我必须写在这里。我的整数是600000000 ex。我想像这样转换它:600,000,000。我该怎么做?
答案 0 :(得分:0)
extension Int {
struct Number {
static let formatter = NSNumberFormatter()
}
var addThousandSeparator:String {
Number.formatter.groupingSeparator = "."
Number.formatter.numberStyle = NSNumberFormatterStyle.DecimalStyle
return Number.formatter.stringFromNumber(self)!
}
}
let myInteger = 600000000
let myIntegerString = myInteger.addThousandSeparator // "600.000.000"