0

I have a storyboard that contains a main window (with a corresponding MainWindowController class), and a main view (an NSSplitViewController, with corresponding MainViewController class). For certain functionality I am attempting to set the delegate of the NSSplitView contained in the view to the MainWindowController class.

Without any IB linkage, the NSSplitView delegate is already set to the MainViewController at application launch. I am able to get a reference to the MainWindowController, but when I attempt to set the delegate to the window controller (which does implement NSSplitViewDelegate), I am getting the following:

*** Assertion failure in -[NSSplitView setDelegate:], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1404.34/AppKit.subproj/NSSplitView.m:600

This also happens if I attempt to set the delegate to nil.

Does anyone know why this might be so, whether there are restrictions on setting delegates, and if there is a way to use IB to set the delegate of an item in a view to another Controller?

Thanks.

Darren Oster
  • 9,146
  • 10
  • 48
  • 66

1 Answers1

1

I don't have a reference for this but I'm pretty sure the split view and the split view controller aren't meant to be separated. Fortunately, NSSplitViewController mirrors the delegate methods, giving you a chance to intervene. There should therefore be no reason to change the split view's delegate.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135
  • 1
    Yes, the penny drops. After all, what is the point of using an NSSplitViewController if the split view doesn't use it? In the end, it was a matter of implementing the protocol calls within the View Controller and the Window Controller and then calling a shared method to handle them. (The scenario was wanting a split view in the title bar to track the split view in the main view). Thanks for the help. – Darren Oster Mar 21 '16 at 03:08