• 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: making a key depend on keypaths of self
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: making a key depend on keypaths of self


  • Subject: Re: making a key depend on keypaths of self
  • From: Phil Frost <email@hidden>
  • Date: Wed, 16 Nov 2005 10:31:17 -0500

On Tue, Nov 15, 2005 at 09:53:32PM +0000, Wain wrote:
>
> On 15 Nov 2005, at 20:09, Phil Frost wrote:
> >
> >The problem then is that I don't know how I'd send notifications.
> >From what I can tell the only way is to call
> >will/didChangeValueForKey: and friends, but firstly I could never
> >call willChange... before making  the change since I don't receieve
> >notification until after it has  happened, and secondly these methods
> >work only for keys, and not keypaths.
>
> You say you receive notification after 'it' has happened, this would
> indicate that you are already receiving a notification (presumably on
> the owning parent  node), in which case you should be able to update
> the sum 'manually'.
>
> If this is incorrect please give a little more information, i.e. are
> you using Core Data and NSManagedObject or are you creating new node
> instances in some  other way?

I would receive the notification through the usual KVO mechanism of
observeValueForKeyPath:ofObject:change:context:.

I am not using CoreData, but rather something I wrote that is roughly
like it.

Shortly after I made the original post (as always happens) I realized
that I could call [parentNode willChangeValueForKey:@"total"] and also
[self willChangeValueForKey:@"price"] when changing the price, and then
the matching didChange methods. However, it didn't seem to work as I
tried it. The setup was rather complex and I have yet to simplify it
enough to find the problem. However, unless someone can tell me that
this approach should not work, or suggest a better solution, I'll assume
it should work and I'm doing something wrong.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >making a key depend on keypaths of self (From: Phil Frost <email@hidden>)
 >Re: making a key depend on keypaths of self (From: Wain <email@hidden>)

  • Prev by Date: Re: Hard linked files cannot be modified
  • Next by Date: API to determine the location of a NSFont's .ttf file
  • Previous by thread: Re: making a key depend on keypaths of self
  • Next by thread: loadHTMLString:baseURL: display behavior
  • Index(es):
    • Date
    • Thread