I have a single window MacOS X application.
I'm having some problem understanding how to connect some parts of the MainMenu.xib NIB file.
What I need to do is to be able to do some stuff in MainMenu's (void)windowDidLoad
function. I just don't know how to connect the MainMenu.xib file to a .m file.
I created a NSObject file in the NIB file which I then connected to a file called MainController and do a lot of stuff there that works.
EDIT
OK, to clearify my question:
Let's say I create a new Project (I'm using Xcode 4.3.2).
I choose File > New > Project, there I choose Mac OS X > Application > Cocoa Application
I press next, set the Product Name as Awesomesauce, uncheck all of the check boxes, press Next and finally choose a folder to store my project in.
I now have 3 files AppDelegate.h
, AppDelegate.m
and MainMenu.xib
(I also have some stuff in the Supporting Files folder which I don't think I need to think about).
I want to have a NSWindowController
file that I can connect to to MainMenu.xib
. I create a new file (Objective-c Class > NSWindowController) and name it MainMenuController
.
Now I open the MainMenu.xib, choose File's Owner under Placeholders and under the Identity Inspector I set the Custom Class > Class as MainMenuController
.
Righ clicking File's Owner I create a connection between window
and Window - Awesomesauce
.
I also add <NSApplicationDelegate>
to MainMenuController.h and create a connection between Window - Awesomesauce delegate
and File's Owner
At this time my MainMenuController looks like this:
@implementation MainMenuController
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if (self) {
NSLog(@"Initializing MainMenuController");
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
NSLog(@"Window did load");
}
- (void)windowWillLoad{
NSLog(@"Window will load");
}
@end
When I run my application I get the Awesomesauce window but none of the NSLog's logs anything. That includes the NSLog in the init method.
What am I doing wrong?