swift3.0中金额计算方法

funcstringFormatToThreeBit(str:String) ->String{

ifstr.characters.count<=0{

return""

}

lettempRemoveD = str.replacingOccurrences(of:",", with:"")asNSString

letstrM =NSMutableString.init(string: tempRemoveD)

varn =2

foriin((0+1)...tempRemoveD.length-3).reversed(){

n +=1

ifn ==3{

strM.insert(",", at: i)

n =0

}

}

returnstrMasString

}

你可能感兴趣的:(swift3.0中金额计算方法)