Hello All,

While determining if the 10.4+ formatter has a bug re failing to call the overridden setNilValueForKey: (which I have determined that it does), I wrote the following code:

- (void)setNilValueForKey:(NSString *)key
{
        if ([key isEqual:@"unformattedNumber"])
        {
NSLog(@"unformattedNumber is %f and firing setNilValueForKey:", [self unformattedNumber]);
                [self setUnformattedNumber:0.0];
                NSLog(@"unformattedNumber is %f", [self unformattedNumber]);
        }
        else if ([key isEqual:@"formatted100Number"])
        {
NSLog(@"formatted100Number is %f and firing setNilValueForKey:", [self formatted100Number]);
                [self setFormatted100Number:0.0];               
                NSLog(@"formatted100Number is %f", [self formatted100Number]);
        }
        else if ([key isEqual:@"formatted104Number"])
        {
NSLog(@"formatted104Number is %f and firing setNilValueForKey:", [self formatted104Number]);
                [self setFormatted104Number:0.0];               
                NSLog(@"formatted104Number is %f", [self formatted104Number]);
        }
        else
        {
                [super setNilValueForKey:key];
                NSLog(@"default setNilValueForKey: fired by Object Controller");
        }
                        
}

And I added three text fields that are bound to SingleObjectFormatterTester.unformattedNumber, SingleObjectFormatterTester.formatted100Number, and SingleObjectFormatterTester.formatted104Number respectively (setNilValueForKey: is overridden and the accessors for all three ivars exist in SingleObjectFormatterTester and an NSObjectController in IB was created for this obj-c class).

Everything works as expected--when I enter an empty value (nil) into the text field bound to unformattedNumber, setNilValueForKey: gets called and the NSLog statements in the console prove that unformattedNumber has been changed to 0.0 for the nil entry. The same thing happens for the formatted100Number (which has a 10.0+ number formatter attached). And, as noted in a prior email, entry of nil into the formatted104Number text field never fires the overridden setNilValueForKey: and the error exception alert panel drops down.

However, the two text fields (that are bound to unformattedNumber and formatted100Number respectively) never get updated to display 0.0. Everything is KVC-KVO compliant and all three fields are init'd to 5.0 (displaying perfectly).

Shouldn't [self setUnformattedNumber:0.0] automatically notify the bound text field via KVC-KVO?
Is there something I'm missing?

Thanks in advance.

Marc
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to