Initialisation and awakeFromNib being called multiple times
Initialisation and awakeFromNib being called multiple times
- Subject: Initialisation and awakeFromNib being called multiple times
- From: "Marc Wan" <email@hidden>
- Date: Wed, 27 Sep 2006 09:30:29 +0800
hello!
I have a Cocoa Application with a Controller class, which controls the
main application window (the app shows only one window and goes away when
that window closes). The Controller class is also, however, the File's
Owner for my application's Preferences dialog nib and its classes. From
what I can see in the debugger, the Controller's -awakeFromNib method is
called twice, once for each Nib, and that seems quite reasonable.
Now, the problem is, I have some initialisation code I want to execute
only after the entire first nib is loaded and all the various IBOutlets have
been set up by the loading code. I don't want it to be executed when the
Preferences dialog is being shown. I can't use either the Controller's or
NSWindow's various -init methods, because the IBOutlets aren't all set up
yet.
So, the best I have so far is:
<code>
- (void)awakeFromNib
{
if (![mainWindow isVisible])
{
/** do initialisation code here. */
}
}
</code>
This, however, makes me want to go to Baffin Island and club baby seals.
Is there some better way to do this? Am I archimatecturing my program
badly? Is there a better place to execute this kind of init code?
Thanks,
marc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden