What is the proper way to pass data between two view controllers inside a NSSplitViewController?

眉间皱痕 提交于 2020-01-24 19:34:08

问题


Overview: My app structure looks like this:

NSSplitViewController
`- SidebarViewController
|  `- NSOutlineViewController
|     `- NSTreeController
|       `- SidebarEntity (static)
`- ContentViewController
   `- NSTableViewController
      `- NSArrayController
         `- ContentEntity (CoreData)

Task: I would like to filter ContentEntity list based on selection in the sidebar.

Problem: I have no idea what is the proper way to pass selection changes over from SidebarVC to ContentVC.

Environment: XCode 8.2.1, Swift 3, OS X 10.11.6


回答1:


After browsing through Cocoa related books I've found the solution that is considered the "proper" one. I sould create a SidebarVCDelegate protocol with proper method for receiving sidebar selection change, make proper filtering method inside ContentVC, and make the NSSplitController a delegate for the Sidebar, filtering the result set based upon the call from delegate.



来源:https://stackoverflow.com/questions/41727151/what-is-the-proper-way-to-pass-data-between-two-view-controllers-inside-a-nsspli

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