0

I would like to clear all items out of an NSTreeController that I added using Controller.AddObject. Is this possible? I presume it is possible to retrieve all the index paths, sort by depth in reverse and remove the items one by one, but I'm hoping for a way just to clear the data.

tofutim
  • 22,664
  • 20
  • 87
  • 148

1 Answers1

0

Simply replace the whole tree model by calling setContent: on your NSTreeController.

This removes everything but makes adding new elements impossible:

[treeController setContent:nil];

Prefer to replace it with an empty collection instead:

[treeController setContent:@[]];

Depending on your model, you might need to do additional set-up for the collection.

ctietze
  • 2,805
  • 25
  • 46