Why doesn't NSNumberFormatter in 10.4 style autolocalize the decimal separator?

It recently occurred to me that using the NSNumberFormatter installed for "OS X 10.0 Behavior" may no longer be in vogue. Therefore, I changed the number of formatter attached to multiple NSTextFields to "10.4 default behavior" and decimal style.

Everything works fine, except that the number of the formatter no longer automatically localizes its decimal separator after switching from US (.) To German (,). I seem to be stuck with what was the active decimal separator when creating the number format in IB.

The β€œlocalize” checkbox in IB does not have an effect, as expected, because setLocalizesFormat: is documented to work only for formatters in the 10.0 style (leaving me wondering why the checkbox is even there).

In my workaround, the custom subclass NSNumberFormatter is now configured in IB as follows:

- (void) awakeFromNib
{
    self.decimalSeparator = [[NSLocale currentLocale] objectForKey:NSLocaleDecimalSeparator];
}

I can’t believe that the correct way to do it, like formatting 10.0 style, did not have this problem.

Any ideas what I am missing?

Regards, Ilja

+3
source share
1 answer

Ive confirmed that you found an error in the Xcodes interface builder - it froze from the grouping separator during XIB creation, which it should not do if the "Locate" checkbox is selected. Please write RADAR.

, ( , ..) :

self.textFieldCell.formatter = [NSNumberFormatter new];
((NSNumberFormatter *)self.textFieldCell.formatter).numberStyle = NSNumberFormatterDecimalStyle;
+3