Search code examples
objective-cmacoscocoansoutlineviewnstreecontroller

How to dynamically update an NSTreeController and NSOutlineView?


When an outlineViewItem is expanded -

 (void) outlineViewItemDidExpand:(NSNotification *)notification

-, I'm able to successfully add an object to the TreeController (log statements show the newly added object in the correct place of the hierarchy), but the OutlineView/UI isn't updating to reflect that insertion.

To no avail, I've used

  • [self.outlineView reloadItem:nil reloadChildren:YES],

  • [self.outlineView reloadData], and even

  • [self.outlineView setHidden:YES] then
    [self.outlineView setHidden:NO]

to try to force reload the structure.

This is all done programmatically in Objective-C.


Solution

  • 6 hours later, I got it.

    I needed to update the NSTreeController cache, which is achieved via the rearrangeObjects method.

    So the answer to my question is:

    [self.cloudDirectoryTreeController rearrangeObjects];