I configured NSNumberFormatter to convert amounts that are stored as cents to NSDictionary for euros. Since they are stored as cents, I set the multiplier formatter to [NSNumber numberWithDouble:0.01] . However, when I try to display 304 euro cents in euros, I get € 3,00 .
This makes me think that the multiplier performs integer division instead of double division.
NSFormatter Configuration
+ (NSNumberFormatter *)euroCurrencyFormatter { static NSNumberFormatter *numberFormatter = nil; @synchronized(self) { if (!numberFormatter) { numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [numberFormatter setMultiplier:[NSNumber numberWithDouble:0.01]]; NSLocale *nlLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"nl_NL"]; [numberFormatter setLocale:nlLocale]; [nlLocale release]; } } return numberFormatter; }
Call NSFormatter
cell.detailTextLabel.text = [[NSNumberFormatter euroCurrencyFormatter] stringFromNumber:[breakdown valueForKey:@"VatAmount"]]; // The VAT amount would be 304.
Result
€ 3,00
How to stop jerky behavior?
source share