Proper way to load child Window/Controller?
Proper way to load child Window/Controller?
- Subject: Proper way to load child Window/Controller?
- From: "Jason Sallis" <email@hidden>
- Date: Mon, 9 Jul 2007 15:34:45 -0600
I'm working on my first semi-real Cocoa app and am having a problem. The
app that runs as a Status Item with a menu which loads a main window. From
that window, I want to spawn child windows. What I currently have happening
is when the user clicks a button in the main window, I call a method which
has the following code to show the Preferences window:
[preferencesController showWindow:self];
In the init method of preferencesController, I have this code which
associates the controller with the nib:
- (id)init
{
if (self = [super initWithWindowNibName:@"Preferences"]) {
projectService = [[ProjectService alloc] init];
[self loadProjects];
}
return self;
}
This worked fine up until now when I need to access a table control from the
Preferences window in my PreferencesController object. Since my controller
was created outside the nib instead of being baked in, I have no outlet set
to access the table. I'm sure I could get a reference to it in a really
convoluted manner, but it seems like I shouldn't need to. Ideally, I should
probably have the controller baked right into the nib (I think) so that I
can set the outlet and go about my business as usual. So, what I tried to
do was change the code to load the nib directly (with the controller baked
in) instead of creating a controller directly, like so:
[NSBundle loadNibNamed:@"Preferences" owner:self]
This didn't quite work as expected. Instead of showing the window, I
get a second instance of my status item for some reason. No crash, no
warnings or errors. But not what I expected.
So, can anyone give me some direction on the recommended way to go about this?
_______________________________________________
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