I need to change a textfield.text from one number to another but retain the regional use of comma or period for decimal eliminator.
A
NSNumberFormatter* nf = [[NSNumberFormatter alloc] init]; nf.locale = [NSLocale currentLocale]; NSNumber *n = [nf numberFromString:textfield.text]; //converts comma to period if needed
float number = [n floatValue];
float newnumber= number * factor;
B
Now I need to reload into the textfield.text the new number as string and convert period to comma if called for by the region. In other words reverse engineer the first step.
NSNumber *n = [NSNumber numberWithFloat: number]; //say number is 17.22000
textfield.text =[nf stringFromNumber: n];
Doesn't work as truncates to the period "17" Is there a reverse of "A" ??