1

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 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

100% correct. The required code first sets the splitviewitem to nil and then sets it with a new vc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.