I have a document-based Mac application that uses storyboards. The document window has a split view controller. My application creates PDF files, and I want to preview the document's PDF in my application. In the storyboard I create a window controller and a view controller for the preview window. In the document window's toolbar I have a Preview item. I create a segue to show the preview window when the Preview item is clicked.
The preview window's view controller needs to access the split view controller so it can get the document to display the PDF in the preview window. My first attempt was to use the presentingViewController property in viewDidLoad() to access the split view controller, but presentingViewController was nil.
My next attempt was to subclass NSViewController and NSWindowController and implement prepareForSegue(), with the split view controller being the segue's source view controller. But prepareForSegue() doesn't get called. I made sure to set the custom class of the preview window controller and view controller to my subclasses in Interface Builder.
How do I access the split view controller from the preview window if presentingViewController is nil and prepareForSegue() doesn't get called?