I've created a new cocoa application using .xib files (not storyboarded, the app has to be backwards compatible with mavericks/mountain lion) and I would like to have a custom windowcontroller for the main window. Is this possible? I can't seem to find a way to connect the window to my desired custom controller. The window has a reference outlet in AppDelegate, however I need a custom NSWindowController for this window as it doesn't open on application launch. The application launches silently as a menu bar app and the main application is launched via button press in the drop down from the menu bar.
Is there a way to link a controller to the window in the interface builder? Or do I have to do something along the lines of :
wc = [[CustomWindowController alloc] initWithWindowNibName:@"Main"];
Yes, open up
Utilities (the right panel) in Interface Builder, and at the bottom click on the
Object Library (circle with square in it).
Object (blue cube), and drag it into your
Document Outline (the panel on the left inside of interface builder)
From there, select that object you just created, and change the
Class in the
Identity Inspector to be the window controller you want.
Finally you can go into the
Connections Inspector and connect your
window to the