I don't understand how NSNumberFormatterPercentStyle works!
Example:
NSNumber *number = [NSNumber numberWithFloat:90.5];
NSNumberFormatter *percentageFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[percentageFormatter setNumberStyle:NSNumberFormatterPercentStyle];
NSString *strNumber = [percentageFormatter stringFromNumber:numbericString];
NSLog (strNumber); // Output: 9,050%
I simply want to show "90.5%" (respecting NSLocal). What is NSNumberFormatterPercentStyle doing with 90.5, and why? And, how can i get my desired result!?
Just set the multiplier to 1
if your numbers are already in percentage.
numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
[numberFormatter setMaximumFractionDigits:0];
[numberFormatter setMultiplier:@1];