tofutim
tofutim

Reputation: 23394

Remove all items from NSTreeController

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.

Upvotes: 0

Views: 236

Answers (1)

ctietze
ctietze

Reputation: 2932

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.

Upvotes: 0

Related Questions