I am getting what feels like a bug when trying to custom instantiate a window controller from a storyboard. I am using NSStoryboard.instantiateController(identifier: creator: ). The block of code in question is:
let mainWindowController = storyboard.instantiateController(identifier: "Analysis Window Controller") { aDecoder in
MainWindowController(coder: aDecoder)
}
I have SUCCESSFULLY used basically this exact code for custom instantiating the main view controller, and just assigning that view to a new window and a new window controller. That works fine. I can also instantiate the window controller the old fashioned way without custom initialization with instantiateController(identifier:). But when I try the above code for custom instantiation of the window controller I end up with the following error:
Assertion failure in -[NSClassSwapper _createControllerForCreator:coder:]...Custom instantiated controller must call -[super initWithCoder:]
Note that both my custom view controller class (which works) and my custom window controller class MainWindowController (which doesn't work) have implemented:
required init?(coder: NSCoder) {
super.init(coder: coder)
}
I know that this functionality is new as of OS 10.15, but the documentation says it should work for window controllers AND view controllers, and the error message does not make any sense to me. https://developer.apple.com/documentation/appkit/nsstoryboard/3203780-instantiateinitialcontroller