Re: NSTreeController, minus set mutation, array exception
Re: NSTreeController, minus set mutation, array exception
- Subject: Re: NSTreeController, minus set mutation, array exception
- From: Ken Victor <email@hidden>
- Date: Mon, 18 Jun 2007 13:49:22 -0700
At 1:27 PM -0700 6/18/07, mmalc Crawford wrote:
On Jun 18, 2007, at 1:02 PM, Ken Victor wrote:
i've got an outline view bound via a tree controller. the tree
controller has its content set bound to a mutable set in my model.
if i attempt to delete several items via the following, everything
works as expected:
NSEnumerator* en = [itemsToDelete objectEnumerator];
while (id anItem = [en nextObject]) {
NSSet* delSet = [NSSet setWithObject: anItem];
[myController willChangeValueForKey: @"proxySet"
withSetMutation: NSKeyValueMinusSetMutation
usingObjects: delSet];
Why are you invoking the KVO change notification methods on the
controller's behalf?
And is there any reason why you are not just modifying your model
directly rather than asking the tree controller to do it?
sorry, poor choice of variable names. i "cleaned up" the code for
posting here and did a really bad job. in the above, myController is
actually a model object that contains the mutable set proxySet... my
sample code would have been better as:
NSEnumerator* en = [itemsToDelete objectEnumerator];
while (id anItem = [en nextObject]) {
NSSet* delSet = [NSSet setWithObject: anItem];
[myModelObject willChangeValueForKey: @"proxySet"
withSetMutation: NSKeyValueMinusSetMutation
usingObjects: delSet];
[[myModelObject proxySet] removeObject: anItem];
[myModelObject didChangeValueForKey: @"proxySet"
withSetMutation: NSKeyValueMinusSetMutation
usingObjects: delSet];
}
and:
[myModelObject willChangeValueForKey: @"proxySet"
withSetMutation: NSKeyValueMinusSetMutation
usingObjects: itemsToDelete];
[[myModelObject proxySet] minusSet: itemsToDelete];
[myModelObject didChangeValueForKey: @"proxySet"
withSetMutation: NSKeyValueMinusSetMutation
usingObjects: itemsToDelete];
ie, i'm modifying my model (proxySet) directly. i've found
empiracally, that if i don't invoke the will/did change notifications
that the changes aren't picked up by the outline/tree controller.
ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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