swiftmacosnsstoryboardnssplitviewcontroller

Instantiating split view controller by identifier in OS X storyboard does not load view hierarchy


I'm trying to implement a master-detail-detail view in a Swift OS X application. The top-level view controller is an NSSplitViewController with three subview controllers. The master and first detail views are fairly standard with fixed behaviors. The second detail view needs to change according to the selection in the first detail view.

The second detail controller is a simple view controller, which will respond to selection changes in the first detail view by installing a new subview and controller depending on the selection.

The alternate view controllers for the final content are implemented in the same storyboard, not connected to anything by segues; the intent is to create them with -[NSStoryboard instantiateControllerWithIdentifier:] and install them as child view controllers and subviews.

The instantiated view controllers happen to be NSSplitViewControllers.

Here's the problem: when I instantiate the detail split view controllers and install them, they are empty. What I have been able to observe so far is:

Is there something I need to do to fully load/populate the loaded split view controllers?

TIA, Doug


Solution

  • Found it. I was trying add the instantiated NSSplitViewController's "splitView" as a subview, rather than its "view" (which contains the splitView). Accessing the "view" property loads the view hierarchy; using the "splitView" did not.