NSOutlineView -- reloadItem:reloadChildren:使我的应用程序崩溃
我正在尝试使用 NSoutlineView 中的 reloadItem
或 reloaditem:reloadchildren
函数重新加载大纲视图中的特定项目,但它使我的整个应用程序崩溃。请告诉我一个解决方法,就像我也尝试折叠该项目并再次展开它,但它没有重新加载该项目及其子项。
现在我正在做的是:
我使用 for 循环手动保存大纲视图的状态,并保存项目(如果其处于展开状态)。
调用 NSOutlineView 的
reloadData
函数然后使用保存的状态,运行 for 循环来展开之前的所有项目展开。
但这种方法的性能开销很大。这种方法还有其他解决办法吗?
有没有什么方法可以自动保存大纲视图的状态并重新加载并再次设置该状态?这些 autosaveExpandedItems 和 setautosaveExpandedItems 方法有什么作用?
谢谢
I am trying to reload a particular item in my outline view using reloadItem
or reloaditem:reloadchildren
function in NSoutlineView but its crashing my entire application. please can you tell me a workaround for this like I also tried to collapse that item and expand it again but it is not reloading that item and its children.
Right now what I am doing is:
I am manually saving the state of my outline view using a for loop and saving the item if its in expanded state or not.
Calling NSOutlineView's
reloadData
functionThen using the saved state, run a for loop to expand all the items that were previously expanded.
But this method has a lot of performance overhead. Is there any other solution to this method?
Is there any method to auto save the state of outline view and reload it and set that state again? what do these autosaveExpandedItems and setautosaveExpandedItems methods do?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在重新加载过程正在进行时尝试重新加载节点,这是 10.6 中的常见行为。
这个方法(或者一些更深层次的相关方法)在10.6中得到了改进。实际上有一个 NSAssert,但是当您在启动时加载 awakeFromNib 中的节点时,由于处理“不一致异常”的正确异常处理程序的泄漏,它感觉会崩溃。
This is a common behavior in 10.6 if you try to reload a node while a reload process is in progress.
This method (or some deeper related methods) was improved for 10.6. Actually there is an NSAssert but it feels like a crash when you are loading the node in awakeFromNib on startup due to the leak of a proper exception handler that handles 'inconsistence exception'.
可能是同步问题,尝试在 reloadItem 周围使用 NSLock 或 @synchronize 。
请附上这个问题的一些来源吗?
probably synchronization issue, try to use NSLock or @synchronize around the reloadItem.
can attach some source to this issue please?