• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Text Fields not Updating when Overridden setNilValueForKey: Called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Text Fields not Updating when Overridden setNilValueForKey: Called


  • Subject: Text Fields not Updating when Overridden setNilValueForKey: Called
  • From: Marc Blatt <email@hidden>
  • Date: Sun, 24 Aug 2008 19:48:05 -0700

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 (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


  • Prev by Date: Re: CFBoolean
  • Next by Date: Re: How to control the order of enumerating on a NSDictionary
  • Previous by thread: Re: CFBoolean
  • Next by thread: Re: Interface Builder misbehaving while designing toolbars
  • Index(es):
    • Date
    • Thread