• 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
KVO and array item observation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KVO and array item observation


  • Subject: KVO and array item observation
  • From: Ashley Clark <email@hidden>
  • Date: Tue, 28 Oct 2008 02:13:23 -0500

I have a bid revision object that holds a to-many NSSet reference to a group of items that constitute a tree. Some of those items are roots and have a nil parent. In my bid revision object I've set up a rootItems method that uses a predicate to return a filtered set of the items with nil parents and uses keyPathsForValuesAffectingRootItems to be aware of changes to the items set as a whole and generate appropriate KVO notifications.

I have a problem though that when an item that's already in the set, but not a root, becomes a root by having its' parent set to nil. This does not cause KVO notifications to be sent out for the rootItems property because technically the items set as a whole has not changed.

I naïvely tried to add @"items.parent" to the keyPathsForValues... method which of course didn't work since you can't observe groups of properties in a set or array. Right now, I'm sending a willChange/ didChange method pair after performing parent changes of subitems and after undo/redo events and it *seems* to be working fine. This seems grotesque though and sure to cause me problems later.

Is there any way to force a KVO update of a property besides a willChange/didChange method pair?
Is there a better way?


Ashley_______________________________________________

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


  • Follow-Ups:
    • Re: KVO and array item observation
      • From: Ashley Clark <email@hidden>
  • Prev by Date: Re: If the NIB instantiates everything how does the controller get a reference to the View and the Model?
  • Next by Date: Re: Problems when putting a window between desktop and desktop icons
  • Previous by thread: Re: NSPredicateEditor error
  • Next by thread: Re: KVO and array item observation
  • Index(es):
    • Date
    • Thread