Search code examples
cocoadatasourcensoutlineview

NSOutlineView's noteNumberOfRowsChanged isn't equivalent to reloadData


I add another Object to my NSOutlineView's NSOutlineViewDataSource and call [myOutlineView noteNumberOfRowsChanged]. If I read the documentation correctly this should get the OutlineView to realize I added one row and redraw itself properly. But instead nothing happens.

If I call [myOutlineView reloadData] it works, but according to the documentation reloadData has a much higher overhead than noteNumberOfRowsChanged (since it reloads all data ... duh)

I'm not using bindings, I supply NSOutlineViewDataSource myself.

Anyone know what I'm doing wrong?


Solution

  • From the reloadData: documentation:

    If you just want to update the scroller, use noteNumberOfRowsChanged; if the height of a set of rows changes, use noteHeightOfRowsWithIndexesChanged:.

    To me that sounds like that noteHeightOfRowsWithIndexesChanged: only ensures that the newly added object is visible within the view.

    The discussion section of the reloadData: documentation also mentions a way to update a single row. But it seems that reloadData: is the only option if you add new objects.