Skip navigation.
 
mlKVO and array item observation
FROM : Ashley Clark
DATE : Tue Oct 28 08:13:23 2008

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_removed>)

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:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>

This email sent to <email_removed>

Related mailsAuthorDate
mlKVO and array item observation Ashley Clark Oct 28, 08:13
mlRe: KVO and array item observation Ashley Clark Oct 28, 22:30
mlRe: KVO and array item observation Ashley Clark Oct 29, 00:27