Another NSTreeController/NSOutlineView/NSIndexPath Question
Another NSTreeController/NSOutlineView/NSIndexPath Question
- Subject: Another NSTreeController/NSOutlineView/NSIndexPath Question
- From: Dave <email@hidden>
- Date: Wed, 10 Jun 2015 20:36:03 +0100
Hi All,
Is there any documentation available on NSTreeController other than the Reference Manual? I’ve found confusing and contradictory comments on NSTreeController and I’d like clarification if possible.
I’m confused about how Index Paths are used. I have a ViewController that is uses a NIB based Outline View and Tree Controller, it is based on the SourceView project. This works fine, but now I’ve got to add some data to another section.
I have flat array of ID Strings that represent objects in a Hierarchy, these take the form:
RootContainer
RootContainer ~ContainerA
RootContainer ~ContainerB
RootContainer ~ContainerA~LeafA
RootContainer ~ContainerA~LeafB
RootContainer ~ ContainerB ~LeafA
RootContainer ~ ContainerB ~LeafB
The Array is sorted so that the lowest items in the Hierarchy appear in the list first. For instance for the above ID array, I would create:
Root Node (Container) Index Path n (the next available section in the Root)
ContainerA Index Path :n.0
ContainerB Index Path :n.1
LeafA Index Path :n.0.0
LeafB Index Path :n.0.1
LeafA Index Path :n.1.0
LeafB Index Path :n.1.1
I am using "insertObject: atArrangedObjectIndexPath:" to Insert Objects into the Tree. My confusion lies in how to compute the Index Paths. I had thought to scan the ViewController/TreeController “ContentArray” to find the initial Index Path, but is this safe? I other words does the position of a Node in the “ContentArray” Hierarchy correspond to the position I need to pass to " insertObject: atArrangedObjectIndexPath:” ?
The only other way I can see of doing it would be to use the TreeController’s “Current Selection” Methods, but they are quite cumbersome to use and seem to slow it down a *lot*, so I’d rather avoid doing it this way if possible.
Thanks for any help or suggestions.
All the Best
Dave
_______________________________________________
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