views:

113

answers:

1

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

A: 

It appears that the right way to do things -- or at least, a way -- is to use -insertObject:atArrangedOjectIndexPath. First create "representedObject", create a new NSTreeNode with that represented object, then insert it. More work than a simply connecting the add button to the tree controller, but (hopefully) the advantages of using NSTreeNode make up for it.

John Velman