我想格式化一个NSNumberFormatter的数字,以便显示为这样的货币:
NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
NSNumber *myNumber = [NSNumber numberWithDouble:[@"0.058" doubleValue]];
[numFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
这给了我0,06 €
。但我希望它是5,8 ct
。有什么想法吗?
答案 0 :(得分:3)
您可以像这样配置NSNumberFormatter:
NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
[numFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numFormatter setCurrencySymbol:@"ct"];
[numFormatter setMultiplier:100];
NSNumber *myNumber = [NSNumber numberWithDouble:[@"0.058" doubleValue]];