0

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
John
  • 2,410
  • 1
  • 19
  • 33

1 Answers1

1

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).

user965972
  • 2,489
  • 2
  • 23
  • 39
  • 100% correct. The required code first sets the splitviewitem to nil and then sets it with a new vc – John Feb 24 '16 at 00:35