Master-detail using bindings with TWO NSTableViews

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:42:39

问题


I have a list of objects displayed in an NSTableView (bound to an NSArrayController). When you select an object in that list I want to show a detail view in a second NSTableView. My object has an array property. I can't figure out how to wire the bindings for this. binding to NSArrayController's selection doesn't work, as that's a single object, and NSTableView expects to be bound to an array...


回答1:


Create a second NSArrayController and bind its contents to the first controller using a keypath of selection.<name of your object's array property>.

So, if your first table view is displaying objects of class Person and your Person class has a children property, you would bind the second array controller to selection.children.

You need a separate array controller for each array that you want to manage in a table view.



来源:https://stackoverflow.com/questions/8160931/master-detail-using-bindings-with-two-nstableviews

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