addChild, etc. using NSTreeController and NSTreeNode (snow leopard)

Posted by John Velman on Stack Overflow See other posts from Stack Overflow or by John Velman
Published on 2010-05-31T00:04:29Z Indexed on 2010/05/31 0:12 UTC
Read the original article Hit count: 312

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

© Stack Overflow or respective owner

Related posts about snow-leopard

Related posts about nstreecontroller