I need to add comma separating numbers into three digits without white spaces and if total digits are under three, then no comma added.
For example:
2984 => 2,984
297312984 => 297,312,984
298 => 298
How do I solve this?
Tried this:
if([textfield.text length] > 3)
{
NSMutableString *stringtext = [NSMutableString stringWithString:textfield.text];
[stringtext insertString:@"," atIndex:0];
}
Abt after starting, started to think if there is a better solution? This is because there will be a lot of if-else statements.
Welcome to any suggestion.