Hoping someone wouldn't mind heading me in the right direction. Seems to me this should be an easy google but i just can't seem to find what works.
Trying to update a textfield with a U.S. currency value while the user types. This is what I have below but I just can't seem to get it to work. I know I'm missing the final setting of the text in the textfield because I assume that is my issue. Thanks for any help.
Trying to update a textfield with a U.S. currency value while the user types. This is what I have below but I just can't seem to get it to work. I know I'm missing the final setting of the text in the textfield because I assume that is my issue. Thanks for any help.
Code:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init]
autorelease];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setGeneratesDecimalNumbers:YES];
[formatter setMaximumFractionDigits:2];
[formatter setMinimumFractionDigits:2];
[formatter setAlwaysShowsDecimalSeparator:YES];
return YES;
}