I want the formatter to show -£4.00 as -£4.00 but it keeps displaying it as (£4.00), why is this ?
This Function below turns strings "00000014" into "£00.14" it should turn negative values too. But the number formatter seems to add brackets.
Code is below:
+(NSString *)pfsCurrencyAmountString:(NSString *)amount CurrencyCodeAsString:(NSString *)code{
if (amount == nil) {
return nil;
}
int amountLength = [amount length];
NSMutableString *amountMutable = [NSMutableString stringWithString:amount];
if (amountLength > 2) {
[amountMutable insertString:@"." atIndex:amountLength - 2];
}
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init];
[currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4];
[currencyStyle setNumberStyle:@"NSNumberFormatterCurrencyStyle"];
[currencyStyle setLocale:locale];
[currencyStyle setCurrencyCode:code];
NSNumber * balance = [currencyStyle numberFromString:amountMutable];
[currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle];
return [currencyStyle stringFromNumber:balance];
}