I created a new empty standard application using the Xcode template. The window in MainMenu.xib is removed, and I created a new customized subclass of NSWindowController with xib.
They were named "WYSunFlowerWindowController.h" and "WYSunFlowerWindowController.m".
And I add the init function as shown below:
- (id)init
{
NSLog(@"init()");
return [super initWithWindowNibName:@"WYSunFlowerWindowController" owner:self];
}
And my WYAppDelegate.m file looks like this:
static WYSunFlowerMainWindowController* windowController = nil;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
if (windowController == nil) {
windowController = [[WYSunFlowerMainWindowController alloc] init];
}
[[windowController window] makeKeyAndOrderFront:windowController];
}
And I have a problem that the window cannot show it on its own after starting the application. Can anyone tell me why? Is there something wrong with my code?
I am new to Objective-C and cocoa. So I think that maybe I'm wrong, I canβt figure it out myself.
UPDATE:
Here is my project source. Please take a look and help me figure out what my mistake is.
https://dl.dropbox.com/u/3193707/SunFlower.zip