I'm trying to configure a NSNumberFormatter to show negative numbers in red. You'd think this would be simple since Apple provides a (rare) code example in the Class documentation that supposedly shows how to do this exact thing.
The code looks like this:
NSMutableDictionary *newAttrs = [NSMutableDictionary dictionary];
[newAttrs setObject:[UIColor redColor] forKey
"NSColor"];
[numberFormatter setTextAttributesForNegativeValues:newAttrs];
No joy. Negative numbers are otherwise correctly formatted, but they're not red.
Then the documentation goes on to say that a more direct way of doing this is to use this code:
[numberFormatter setFormat
"$#,##0.00;[Red]($#,##0.00)"];
This is even worse. Not only aren't negative number red, it actually displays the text "[Red]" in front of negative numbers.
You're my last hope before I spend a tech support issue. Does anyone know how to set negative numbers to display in red using a NumberFormatter?
The code looks like this:
NSMutableDictionary *newAttrs = [NSMutableDictionary dictionary];
[newAttrs setObject:[UIColor redColor] forKey
[numberFormatter setTextAttributesForNegativeValues:newAttrs];
No joy. Negative numbers are otherwise correctly formatted, but they're not red.
Then the documentation goes on to say that a more direct way of doing this is to use this code:
[numberFormatter setFormat
This is even worse. Not only aren't negative number red, it actually displays the text "[Red]" in front of negative numbers.
You're my last hope before I spend a tech support issue. Does anyone know how to set negative numbers to display in red using a NumberFormatter?