NSTreeController and insertObject:atArrangedObjectIndexPath:
NSTreeController and insertObject:atArrangedObjectIndexPath:
- Subject: NSTreeController and insertObject:atArrangedObjectIndexPath:
- From: Tony Romano <email@hidden>
- Date: Fri, 18 Jun 2010 15:53:04 -0700
Scenario: Adding a new node to a NSOutlineView backed by a NSTreeController.
1. Create a new internal object add add it to the data store(file system). This will be my representedObject in the treecontroller
2. Compute the path and call insertObject:atArrangedObjectIndexPath:
the treecontroller does 2 things during the call to insertObject:
1. It calls my getter, children, and asks me for all the children under the parent node I have added the new node to. I give it the list INCLUDING the newly created node since it is now in the store.
2. Then it calls the setter, setChildren, and gives me the newChildren list. Which now has an additional copy of the new node, one from the getter call and one from the insertAt call. I know this for a fact because I purposely added some data to the newly created node for the insert to distinguish them.
From the UI, the outlineview is correct, but my internal child list has the extra node. It's not displayed because the treecontroller optimizes when to ask me for a childlist. I have a work around which I don't like to basically lock out the getter method and just return the current child list(i.e the previous child list which doesn't have the new node added from the file system). Anyone experience this before and have a recommendation?
TIA,
-Tony
_______________________________________________
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