+ (nsstring*) Strmethodcomma: (nsstring*) string
{
Nsstring*sign = nil;
if ([stringhasprefix:@ "-"]| | [String hasprefix:@ "+"]) {
sign = [string substringtoindex:1];
string = [string substringfromindex:1];
}
Nsstring*pointlast = [string substringfromindex:[string length]-3];
Nsstring*pointfront = [string substringtoindex:[string length]-3];
int commanum= ([Pointfront length]-1)/3;
Nsmutablearray *arr = [Nsmutablearray array];
for (int i =0; i < commanum+1; i++) {
int index = [Pointfront length]-(i+1);
int leng = 3;
if (Index < 0)
{
Leng = 3+index;
index = 0;
}
Nsrange range = {Index,leng};
NSString *STQ = [Pointfront substringwithrange:range];
[Arr ADDOBJECT:STQ];
}
Nsmutablearray *ARR2 = [Nsmutablearray array];
for (int i =[arr count]-1; i>=0; i--) {
[ARR2 Addobject:arr[i]];
}
nsstring*commastring = [[arr2 componentsjoinedbystring:@], "]stringbyappendingstring:pointlast";
if (sign) {
commastring = [sign stringbyappendingstring:commastring];
}
returncommastring;
}
Add a separator of thousand points