问题
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