Search code examples
objective-ccocoansoutlineviewappkit

NSOutlineView doesn't call the data source methods


Simple problem: NSOutlineView doesn't call the data source methods.

Datasource is correctly wired in Interface Builder to the correct class object.

It's cell based. I've implemented many NSOUtlineViews before, not sure what's going wrong with this one.

What could be the reason?

- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item

Solution

  • OK after few hours I figured out. This method is not optional as I thought:

    - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
    

    It must be implemented, or the other ones won't be called, as written in documentation, below, in little.

    IMPORTANT While this method is marked as @optional in the protocol, you must implement this method if you are not providing the data for the outline view using Cocoa bindings.