NSNumberFormatter and 10.4 behavior
NSNumberFormatter and 10.4 behavior
- Subject: NSNumberFormatter and 10.4 behavior
- From: Lee Ann Rucker <email@hidden>
- Date: Tue, 17 Jul 2007 11:13:30 -0700
NSNumberFormatter and 10.4 behavior has got me rather confused.
I have a sample app with a custom number formatter that sets 10.4
behavior in its initialize function and nowhere else; that causes the
formatter to get 10.4 behavior even though it's created in the nib
(despite the doc saying formatters created in the nib get 10.0
behavior). Without that line, it gets 10.0.
But I try the same thing in my real app, and I get 10.0. Of course,
my real app has a lot more NSTextFields with numbers in them, and
most of them use the default NSNumberFormatter.
I've got a line to do
[NSNumberFormatter
setDefaultFormatterBehavior:NSNumberFormatterBehavior10_4];
in applicationWillFinishLaunching, but that doesn't help. Even with
initialize setting it to 10.4, it's 10.0.
Tried creating the formatter in code instead of the nib and
discovered that even though I'd already called [NSNumberFormatter
setDefaultFormatterBehavior: once, it was getting called again, from
[NSNumberFormatter initialize], and getting reset to 10.0.
Added code to set it *again* in my custom formatter initialize, and
now the custom formatter is 10.4, but creating NumberFormatters in
code is not so clean as in nibs; the bindings are clumsier in code.
Originally I just did
numberFormatter = [nibTextField formatter];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
but a co-worker didn't like that, because we'd have to remember set
it for every formatter we ever use.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden