Search code examples
objective-cnsoutlineview

How do I add a NSOutlineViewDataSource to my NSOutlineView?


I am writing a System Preference pane for Mac OS X in Objective-C. The panel includes a NSOutlineView bound to a properly configured NSTreeController. I also added a delegate class for my OutlineView in which I defined my own outlineView:viewForTableColumn:item: method.

enter image description here

When I add new objects to the Tree Controller everything works fine, but now I want to enable persistence for expanded items. To do so I need to implement outlineView:itemForPersistentObject: and outlineView:persistentObjectForItem: in a data source for the OutlineView, otherwise I get the error:

*** NSOutlineView data source ((null)) does not implement outlineView:persistentObjectForItem:

How do I do that given my current setup?


Solution

  • The delegate and data source can be the same object. Implement the methods in OutlineViewDelegate and connect the data source the the same object as the delegate.