NSNumberFormatter and localized format problem
NSNumberFormatter and localized format problem
- Subject: NSNumberFormatter and localized format problem
- From: Eric Morand <email@hidden>
- Date: Wed, 26 Apr 2006 15:42:52 +0200
Hi guys !
I'm currently fighting with a text field that is supposed to display
an amount of money. Since the formatters included in Interface
Builder are unusable (completely buggy), I'm trying to create the
formatter in code and set my text field to use this formatter.
I've first initialized my formatter :
NSNumberFormatter * aFormatter = [[[NSNumberFormatter alloc] init]
autorelease];
The problem is that...
[aFormatter setNumberStyle: NSNumberFormatterCurrencyStyle]
...doesn't seem to work. II thought it was supposed to
automatically format a number to match the International preferences
set by the user...but it format my numbers as american type numbers
(1,500.00 instead of 1 500,00 in France).
So, I've set my formatter this way :
[ aFormatter setFormat:@"#,###.00;0.00;#,##0.00"];
[ aFormatter setLocalizesFormat:YES];
And it doesn't work either. If I enter a number greater than 999 in
my text field, I have an error message in the console saying that the
value of the text field should not be nil !
So I tried to remove the setLocalizesFormat call and changed the
format to this (to match the french Format) :
[ aFormatter setFormat:@"# ###,00;0,00;# ##0,00"];
And this time, the positive numbers are formatted without decimal and
with te american thousand separator : 1,500 instead of 1 500,00 !
Am I doing something wrong ? How am I suppposed to display correctly
formatted amount in my text field ?
Thanks for your help,
Eric.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden