The below code i used for formatting the string in textfieldShouldDidEndEditing,
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
long long num = [textField.text longLongValue];
NSString *formattedOutput = [formatter stringFromNumber:[NSNumber numberWithLongLong:num]];
textField.text = formattedOutput;
[formatter release];
I have an issue in above code is, first time its work normally but when we going back to the textfield , and coming out of it , then the value changes.
For example i entered value for first time is 123456789123456789
and got this output 123,456,789,123,456,789
and now when we re-enter and exit from the textfield with or without editing, i am getting the value is 123.
Thanks In Advance
Bhaskar
Of course, because after first call in
UITextFieldis stored123,456,789,123,456,789, not123456789123456789When you are calling second time that method in
numwill be stored123.Try this one:
replace
with