dredzik
dredzik

Reputation: 21

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

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

Upvotes: 1

Views: 426

Answers (1)

dredzik
dredzik

Reputation: 21

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.

Upvotes: 1

Related Questions