直接调用即可
- (NSString *)hanleNums:(NSString *)numbers{
NSString *str = [numbers substringWithRange:NSMakeRange(numbers.length%3, numbers.length-numbers.length%3)];
NSString *strs = [numbers substringWithRange:NSMakeRange(0, numbers.length%3)];
for (int i =0; i < str.length; i =i+3) {
NSString *sss = [str substringWithRange:NSMakeRange(i, 3)];
strs = [strs stringByAppendingString:[NSString stringWithFormat:@",%@",sss]];
}
if ([[strs substringWithRange:NSMakeRange(0, 1)] isEqualToString:@","]) {
strs = [strs substringWithRange:NSMakeRange(1, strs.length-1)];
}
return strs;
}
网友评论