Re: Unexpected behavior of NSNumberFormatter
Re: Unexpected behavior of NSNumberFormatter
- Subject: Re: Unexpected behavior of NSNumberFormatter
- From: Chris Kane <email@hidden>
- Date: Fri, 28 Dec 2001 13:24:56 -0600
On Thursday, December 27, 2001, at 02:02 PM, Nick M|ller wrote:
I'm fiddling around with NSNumberFormatter and don't get what the
documentation seems to promise.
I allocate a NSNumberFormatter, set him to localized and still get the
separators of the default.
// ----
NSNumberFormatter *fmt = [[NSNumbrFormatter alloc] init];
NSLog([fmt decimalSeparator]); // -> "." OK, this is the US-default
[fmt setLocalizesFormat:YES];
NSLog([fmt decimalSeparator]); // -> "." should be "," for DE
// ----
What's the right formatter for Numbers that responds to local/non-local
settings? I need one that can be modified.
The setLocalizesFormat: method doesn't do what you expect, and hardly
does anything, if at all, interesting. Only formatters which come out
of .nib files can get correctly localized currently. (Actually, it's
"only formatters which are unarchived" get localized, so presumably one
could archive a formatter to NSData, and unarchive the data (without
dealing with the file system), to get a localized formatter.) Apple has
a bug on this.
Chris Kane
Cocoa Frameworks, Apple