Debugging Nested NSCollectionViews

﹥>﹥吖頭↗ 提交于 2020-01-02 06:23:11

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2204147/debugging-nested-nscollectionviews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!