开发者

How to remove all elements from NSTreeController with NSOutlineController

开发者 https://www.devze.com 2023-02-09 03:19 出处:网络
I am using NSTreeController with NSOutlineController to display contents in 1parent-1child hierarchy.

I am using NSTreeController with NSOutlineController to display contents in 1parent-1child hierarchy. My structure is like this:

- parent

- child

- parent

- child

Now when user press a refresh button, I want to remove all the nodes and refill it again.

[[treeController arrangedObjects] removeAllItems];
[[treeController arrangedObjects] removeAllObjects];

but nothings seems to be working.

I guess binging NSTreeControll开发者_JS百科er with NSArrayController should help but I really don't know steps to bind -NSArrayController-NSTreeController-NSOutlineController.


I do it all the time with unbound lists.

Simple to clear the list:

[treeController setContent:nil];


From the documentation for the content property:

The value of this property can be an array of objects, or a single root object. The default value is nil.

If your content is an array (presumably an NSMutableArray), then

[treeController.content removeAllObjects];

would be appropriate. Setting it to nil removes the underlying container. If your content is a single object, then

treeController.content = nil;

is the correct choice.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号