Re: How to open two nibs at app launch ? Beginners question
Re: How to open two nibs at app launch ? Beginners question
- Subject: Re: How to open two nibs at app launch ? Beginners question
- From: Quincey Morris <email@hidden>
- Date: Mon, 13 Apr 2009 02:15:07 -0700
On Apr 13, 2009, at 01:14, Mario Kušnjer wrote:
But I actually don't understand those application delegate's concept.
How do I make something to delegate to something else (did I even
get that right ?) ?
Application delegate would be (in my case) an object added in
MainMenu.nib that would have MainWindowController class set to it ?
And MainWindow.nib File's Owner is also set to MainWindowController,
right ?
That would be the connection between MainWindow.nib file and the
code to instantiate my window controller.
I'm not sure I doing it right !
So I should put applicationDidFinishLaunching (that would be
instance ?) method in MainWindowController class and inside
instantiate my window controller ?
Not exactly. Make your application delegate (let's say its class is
MyAppDelegate) separate from your window controller. So, the steps are:
-- write a MyAppDelegate class (subclass of NSObject)
-- in IB, drag an object into MainMenu.xib, and set its class to
MyAppDelegate (that causes an instance to be created automatically
when your app starts up)
-- in IB, connect the 'delegate' outlet of the (predefined)
Application object in MainMenu.xib to the MyAppDelegate object (that
causes your MyAppDelegate object to actually *be* the application's
delegate)
-- in your MyAppDelegate class, add an instance variable
mainWindowController, of class MainWindowController
-- in your MyAppDelegate class, write an
applicationDidFinishLaunching: method something like this:
- (void) applicationDidFinishLaunching: (NSNotification *)
aNotification {
mainWindowController = [[MainWindowController alloc] init];
[mainWindowController showWindow: nil];
}
-- your MainWindowController's init method should look something like
this:
- (id) init {
self = [super initWithWindowNibName: @"MainWindow"];
if (!self) ...
...
return self;
}
-- in IB, set the class of File's Owner in MainWindow.xib to
MainWindowController
I may have left out something, but that's the basic idea.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden