Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何动态更新NSTreeController和NSOutlineView?_Objective C_Macos_Cocoa_Nsoutlineview_Nstreecontroller - Fatal编程技术网

Objective c 如何动态更新NSTreeController和NSOutlineView?

Objective c 如何动态更新NSTreeController和NSOutlineView?,objective-c,macos,cocoa,nsoutlineview,nstreecontroller,Objective C,Macos,Cocoa,Nsoutlineview,Nstreecontroller,展开大纲视图项时- (void) outlineViewItemDidExpand:(NSNotification *)notification -,我能够成功地将对象添加到TreeController(日志语句将新添加的对象显示在层次结构的正确位置),但OutlineView/UI没有更新以反映该插入 没用,我用了 [self.outlineView重载项:无重载子项:是] [self.outlineView重载数据],甚至 [self.outlineView setHidden:YES

展开大纲视图项时-

 (void) outlineViewItemDidExpand:(NSNotification *)notification
-,我能够成功地将对象添加到TreeController(日志语句将新添加的对象显示在层次结构的正确位置),但OutlineView/UI没有更新以反映该插入

没用,我用了

  • [self.outlineView重载项:无重载子项:是]

  • [self.outlineView重载数据]
    ,甚至

  • [self.outlineView setHidden:YES]
    然后
    [self.outlineView setHidden:否]

尝试强制重新加载结构


这一切都是在Objective-C中以编程方式完成的。

6小时后,我明白了

我需要更新NSTreeController缓存,这是通过
重新排列对象
方法实现的

因此,我的问题的答案是:

[self.cloudDirectoryTreeController rearrangeObjects];

6个小时后,我明白了

我需要更新NSTreeController缓存,这是通过
重新排列对象
方法实现的

因此,我的问题的答案是:

[self.cloudDirectoryTreeController rearrangeObjects];

您是使用绑定还是仅使用
NSOutlineViewDataSource
-协议方法?我对值、大纲视图内容和索引路径(NSOutlineView)以及内容数组/控制器内容(NSTreeView)使用绑定。我使用的唯一委托是:-(void)outlineViewItemDidExpand:(NSNotification*)通知您使用绑定还是只使用
NSOutlineViewDataSource
-协议方法?我对值、大纲视图内容和索引路径(NSOutlineView)以及内容数组/控制器内容(NSTreeView)使用绑定。我使用的唯一委托是:-(void)outlineViewItemDidExpand:(NSNotification*)通知