+ (NSString *)df_moneyNumJoinThousandSegmentationWithStr:(NSString *)digitString
+ (NSString *)df_moneyNumJoinThousandSegmentationWithStr:(NSString *)digitString
{
NSLog(@"%@", [digitString componentsSeparatedByString:@"."]);
NSArray *array = [digitString componentsSeparatedByString:@"."];
digitString=array[0];
NSString *pointStr=[array[1]description];
if (digitString.length <= 3) {
return [NSString stringWithFormat:@"%@%@%@",digitString,@".",pointStr];
} else {
NSMutableString *processString = [NSMutableString stringWithString:digitString];
int location = (int)processString.length - 3;
NSMutableArray *processArray = [NSMutableArray array];
while (location >= 0) {
NSString *temp = [processString substringWithRange:NSMakeRange(location, 3)];
[processArray addObject:temp];
if (location < 3 && location > 0)
{
NSString *t = [processString substringWithRange:NSMakeRange(0, location)];
[processArray addObject:t];
}
location -= 3;
}
NSMutableArray *resultsArray = [NSMutableArray array];
int k = 0;
for (NSString *str in processArray)
{
k++;
NSMutableString *tmp = [NSMutableString stringWithString:str];
if (str.length > 2 && k < processArray.count )
{
[tmp insertString:@"," atIndex:0];
[resultsArray addObject:tmp];
} else {
[resultsArray addObject:tmp];
}
}
NSMutableString *resultString = [NSMutableString string];
for (int i = (int)resultsArray.count - 1 ; i >= 0; i--)
{
NSString *tmp = [resultsArray objectAtIndex:i];
[resultString appendString:tmp];
}
return [NSString stringWithFormat:@"%@%@%@",resultString,@".",pointStr];
}
}