Ah, thanks. I wonder what the purpose of this subclass is and how fragile this solution?
As of 10.5 it's the Apple-sanctioned way to go! I've used it for ages now, no problems at all. The tree node is a proxy for whatever 'real' item you add to the tree.
You can also get the selectedNodes, which returns treeNode objects, or the selectedObjects, which returns the 'real' obejcts that you've created.
My isGroupItem just compares an NSString *nodeName of the represented object to a list of strings I want to have as groups, i.e @"SOURCES", @"PLAYLISTS", etc.
I'm not convinced I'm going to go the bindings route, as my source list has non-collapsible groups, and making sure they're expanded and not selected when the table is first displayed seems as much trouble as just using a datasource in the first place!
Bindings do make the whole thing a lot easier in the long run, and autosaving of the state just needs a bit of trickery:
1) Subclass NSOutlineView and add a method that simply looks at each row in turn and sees if the itemAtRow is expanded.
2) Add all the expanded items to an array.3) Save the array in your data store, along with the whole tree as you normally would.
4) On loading, set the outline view's content and then pass the 'expanded items' array to another method 'expandItemsInArray' in you NSOutlineView subclass.
5) This method should start at row 1 and compare all the items in the expanded items array to the itemAtRow: if they're the same expand the item
6) When you do this, be sure to update the number of rows as each expansion of an item causes the number of rows to increase.
This works without fail for me, i posted the code that does this a while back, sometime in the last couple of months.
Hope this helps, Jon
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]