• 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: Re: KVO question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: KVO question


  • Subject: Re: Re: KVO question
  • From: Christian Brunschen <email@hidden>
  • Date: Tue, 23 May 2006 17:10:08 +0200 (CEST)



On Tue, 23 May 2006, Peter Boctor wrote:

On 5/23/06, George Orthwein <email@hidden> wrote:

On May 22, 2006, at 8:29 PM, Peter Boctor wrote: > How can the observeValueForKeyPath implementation determine > what actually changed, "current" or "current.bar"?

Isn't this what context is for?

Alternatively, can't you just do an if/then in observeValueForKeyPath:

if ([keyPath isEqualToString:@"current"]) ...
...
else if ([keyPath isEqualToString:@"current.bar"]) ...


I'd like to know when a "current.bar" notification occurred because bar actually changed versus when it occurred because "current" changed. Neither the context nor the keyPath can indicate this.

Sounds to me like you should register for changed on 'current', and whenever 'current' changes, register on changes to current's 'bar'. This way, whenever 'bar' changes within that object, you'll get notified, but if 'current' changes, you will only get notified of the change to 'current', but not the change to 'bar'. Of course this requires that you then, whenever 'current' changes, _un_register for notifications on the old current's 'bar', and _register_ for changes on the _new_ current's 'bar' instead.


Does that makes sense?

-peter

// Christian Brunschen _______________________________________________ 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: 
 >KVO question (From: "Peter Boctor" <email@hidden>)
 >Re: KVO question (From: George Orthwein <email@hidden>)
 >Re: Re: KVO question (From: "Peter Boctor" <email@hidden>)

  • Prev by Date: Re: Re: KVO question
  • Next by Date: Re: iWork Pages Plugin
  • Previous by thread: Re: Re: KVO question
  • Next by thread: Re: view hierarchy inspector (for debugging)
  • Index(es):
    • Date
    • Thread