调试嵌套 NSCollectionView
我不太确定如何开始调试这个问题。
我有一个 NSCollectionView,其 NSCollectionViewItem 原型视图本身包含一个 NSCollectionView (以及一个 NSArrayController,为这个第二级集合视图提供内容)。当顶级视图位于主笔尖时,两个级别的集合视图都可以正常工作。
但是,当我将视图(并重新连接所有适当的绑定)复制/粘贴到新笔尖(使用 loadNibNamed:owner:
加载)时,第二级视图 - 但不是顶级视图 -第一级——显示为空白。
经过一番调查,我发现 myArrayController.arrangedObjects.@count
确实是 0。但是,当询问时,控制器绑定到的 NSArray(文件所有者的 representedObject.quizzes
)对于 .@count
,返回 2。
quizzes
确实应该返回 2,因为我已经完成了 [testCategoryA setQuizzes:[NSArray arrayWithObjects:testQuizA1,testQuizA2,nil] ];
。我已经测试过在笔尖加载之前和之后设置测验。两种情况的情况都是一样的。
所以,总而言之,我有 2 级集合视图,以及 2 级数组控制器。顶层总是有效的。但是只要顶层不在主 nib 文件中,第二层就会中断。在我看来,第二级中断的部分是数组控制器的绑定。
我什至不知道如何在这混乱的笔尖中开始调试。建议?
I'm not really sure how to start debugging this issue.
I've got an NSCollectionView, whose NSCollectionViewItem prototype view itself contains an NSCollectionView (as well as an NSArrayController, to provide content to this 2nd-level collection view). Both levels of collection view work fine when the top-level view is in the main nib.
However, when I copy/paste the view (and reconnect all the appropriate bindings) to a new nib, which I load with loadNibNamed:owner:
, the 2nd-level view--but not the top-level one--appears blank.
Upon some investigation, I discovered that myArrayController.arrangedObjects.@count
is indeed 0. HOWEVER, the NSArray the controller is bound to (File's Owner's representedObject.quizzes
), when asked for .@count
, returns 2.
quizzes
should indeed return 2, for I've done [testCategoryA setQuizzes:[NSArray arrayWithObjects:testQuizA1,testQuizA2,nil]];
. I've tested setting the quizzes before the nibs are loaded and after. The situation is the same in both cases.
So, in conclusion, I've got 2 levels of collection views, with 2 levels of array controllers. The top level always works. But the 2nd level breaks whenever the top level isn't in the main nib file. And it seems to me that the part about the 2nd level that breaks is the binding of the array controller.
I don't even know how to start debugging in this tangled mess of nibs. Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来好像您的测验数组要么没有发送 KVO 通知,要么您正在以不符合 KVO 的方式编辑它(即“在控制器背后编辑数组”)。
此外,您可能需要检查 索引访问器出于性能原因,您的测验数组的方法。
It sounds as though your quizzes array is either not sending KVO notifications or you're editing it in a non-KVO-compliant way (ie, "editing the array behind the controller's back").
Further, you might want to check into Indexed Accessor Methods for your quizzes array for performance reasons.