• 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
Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately


  • Subject: Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
  • From: Brad Gibbs <email@hidden>
  • Date: Tue, 27 Oct 2009 09:21:42 -0700

Thanks for the pointers. I need to learn to rely on the debugger more than log messages.

It also turns out that I had the method wrong. Although + (NSSet) keyPathsForValuesAffectingValueFor<key>: doesn't create any errors, it doesn't get called. The ValueFor near the end of the method is extraneous and causes the method not to get called. I could swear I copied that from the Departments & Employees sample app.

In any case, everything is now working as expected and I learned a few important lessons.

Thanks again.


Brad

On Oct 27, 2009, at 8:59 AM, Jim Correia wrote:

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


References: 
 >keyPathsForValuesAffectingValueFor<key>: not updating immediately (From: Brad Gibbs <email@hidden>)
 >Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately (From: "I. Savant" <email@hidden>)
 >Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately (From: Brad Gibbs <email@hidden>)
 >Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately (From: Jim Correia <email@hidden>)
 >Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately (From: Brad Gibbs <email@hidden>)
 >Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately (From: Jim Correia <email@hidden>)

  • Prev by Date: programmatically determining whether a system would run a GC only app
  • Next by Date: Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
  • Previous by thread: Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
  • Next by thread: Re: keyPathsForValuesAffectingValueFor<key>: not updating immediately
  • Index(es):
    • Date
    • Thread