addChild, etc. using NSTreeController and NSTreeNode (snow leopard)
- by John Velman
I have a setup with an object (OTNodeDatum) (OT for OutlineTest) to be the represented object in NSTreeNode. NSTreeNode is the Class shown in the attributes page for NSTreeController.
I have document based app, no core data. On MyDocument init, I set up content with an NSMutableArray containing one item, an NSTreeNode with a represented object which contains a single property (yes, name).
Add button, Add Child button, Delete button, hooked up via interface builder to the NSTreeController add action, etc.
It works up to a point.
When I do an add, I get a new blank line which I can edit, but the inserted text goes away when I leave the cell.
When I do a delete, things get deleted.
When I do add child, nothing happens.
I think I have to subclass either NSTreeNode, or NSTreeController to get the right behavior in terms of adding children and adding a new represented object in addition to adding a new tree node.
IS this on the right track? If I subclass NSTreeController would I just override the add, addChild, to get the right thing to happen? And what could I mess up? I can't seem to find any guidance on this, although I've spent a long time looking.
Thanks.
John V