• 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: KVO one-step listening but two-step notifying?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO one-step listening but two-step notifying?


  • Subject: Re: KVO one-step listening but two-step notifying?
  • From: Hamish Allan <email@hidden>
  • Date: Fri, 23 Dec 2005 02:23:59 +0000


On Dec 22, 2005, at 7:53 PM, mmalcolm crawford wrote:

On Dec 22, 2005, at 4:14 PM, Hamish Allan wrote:

- (id)property
{
if (_setting)
return [_object1 property];
else
return [_object2 property];
}

First, this sounds suspicious. It's not immediately clear why you would have a pattern like this. That said, it seems like you simply have a dependency -- 'property' is a key that's dependent on 'setting'. If 'setting' is KVO compliant, then you should just be able to use setKeys:triggerChangeNotificationsForDependentKey:...

Thank you; I should be able to make that work fine for my situation. But what about the more general case -- for example what if you were writing an object which merged the contents of two arrays from other objects, so you would want to notify of changes to your array if either of the object's arrays changed?

- (id)mergedArray
{
return [[_object1 individualArray] arrayByAddingObjectsFromArray: [_object2 individualArray]];
}

You can observe changes to each of those individualArrays, but by the time observeValueForKeyPath:... is called it's too late to call willChangeValueForKey:@"mergedArray" because -mergedArray will already be providing the new contents.

Thanks,
Hamish


_______________________________________________
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
  • Follow-Ups:
    • Re: KVO one-step listening but two-step notifying?
      • From: Michel Schinz <email@hidden>
    • Re: KVO one-step listening but two-step notifying?
      • From: mmalcolm crawford <email@hidden>
References: 
 >KVO one-step listening but two-step notifying? (From: Hamish Allan <email@hidden>)
 >Re: KVO one-step listening but two-step notifying? (From: mmalcolm crawford <email@hidden>)
 >Re: KVO one-step listening but two-step notifying? (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: Re: SyncServices: identifier problem
  • Next by Date: NSTableView custom behavior
  • Previous by thread: Re: KVO one-step listening but two-step notifying?
  • Next by thread: Re: KVO one-step listening but two-step notifying?
  • Index(es):
    • Date
    • Thread