Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
- Subject: Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
- From: Jim Correia <email@hidden>
- Date: Tue, 27 Oct 2009 11:59:27 -0400
On Tue, Oct 27, 2009 at 11:39 AM, Brad Gibbs <email@hidden> wrote:
> I don't think there's anything wrong with the method -- I've used it
> successfully in other apps and have seen it work in Apple sample apps, it
> just isn't working in this particular case. I'm sure that there's something
> wrong on my end. Just looking for a little help in figuring out what that
> could be...
We are at the point where we can't offer useful advice without seeing
your code. Since +keyPathsForValuesAffecting<Key> is not fundamentally
broken, the most likely cause is a problem with your code.
> - (NSSet *)keyPathsForValuesAffectingValueForFullAddress {
> return [NSSet setWithObjects:self.streetAddress, self.city,
> self.state, self.zipCode, nil];
> }
This is wrong for 2 reasons.
Reason #1 - see below.
Reason #2 - you should be passing the literal key paths which affect
the value, not self.streetAddress which is the current value of that
key path.
> I've also tried:
>
> - (NSSet *)keyPathsForValuesAffectingValueForFullAddress {
> return [NSSet setWithObjects:@"streetAddress", @"city", @"state",
> @"zipCode", nil];
> }
+keyPathsForValuesAffecting<Key> should be implemented as a class
method. (That's what the + prefix means.) You've implemented it as an
instance method. Change it to a class method and you should find that
it works correctly.
(If you set a breakpoint on your code as written, you'll find that it
is never called, which should be a warning sign to you that something
is wrong.)
- Jim
_______________________________________________
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