Setting SplitViewItem's ViewController

501 views Asked by At

Im having trouble setting a nssplitviewcontroller's split view's view controller. I have a reference from the story board and am trying to set the items view controller programmatically:

   override func viewDidLoad() {
       dash = storyBoard.instantiateControllerWithIdentifier("dash_viewcontroller") as? NSViewController
       print(dash)
       main_view.viewController = dash!
    }

I get this error from the console(doesn't crash) and doesn't show the programmatically set vc:

2016-02-21 10:03:19.475 HealthDash[62950:3960447] Failed to set (contentViewController) user defined inspected property on (NSWindow): Cannot remove a SplitViewItem's viewController if it is currently in a SplitViewController
1

There are 1 answers

1
user965972 On BEST ANSWER

Looks like the splitViewItem has a content controller that is actively being displayed. My guess: first you will have to remove that view controller from screen before you can replace it. Probably easier to create a new NSSplitItemView, add that to the NSSplitViewController and remove unwanted NSSplitItemView (and their associated view controllers).