three windows two nibs
three windows two nibs
- Subject: three windows two nibs
- From: Daniel Child <email@hidden>
- Date: Fri, 18 Jan 2008 18:03:40 -0500
Hi All,
[I am changing the subject title (MV and more than one C) since this
post has drifted far from my original question. ]
Basically, I am trying to understand how you load nibs and work with
window controllers in non-doc apps. In my test application, two
windows (windowA and windowB) are in the MainMenu.nib file, and a
third window (windowC) is in a second nib file, WindowC.nib. The goal
is to have all three windows be able to open each other when you
press the right button. Thus, each window has a button that says
"Open Window X" with X being the window in question.
The way I set it up, it almost works....
There is a main Controller for the MainMenu.nib and its two windows.
These two windows (A and B) can open each other no problem.
I also created a WindowCController class (subclassed from
NSWindowController) to control the second nib file and its window
(WindowC). windowControllerC is allocated and init'd when Controller
loads. This enables me to access windowC from A and B.
- (IBAction) openWindowC: (id) sender
{
[windowA close]; // I don't know which window is open so
[windowB close]; // I closed both. Not elegant. How do you tell
which is currently open?
// Is windowController nil (just to make sure)?
if (!windowCController) {
NSLog(@"Creating windowCController from openWindowC.\n");
windowCController = [[WindowCController alloc] init];
}
NSLog(@"Presumably about to show the window.");
[windowCController showWindow: self];
}
This works (even though closing both windows A and B is not elegant.
(How can you find out which window is open?)
But I can't go the other way around and open windows A and B from
Window C.
I understand that to open a new nib you connect its window to a
subclass of NSWindowController, and designate its File'sOwner to be
the window controller.
But once control is inside of the window controller, how can you get
access backwards to variables inside of the Controller instantiated
inside of MainMenu.nib (where you just came from). In other words,
declaring windowControllerC as an instance variable of Controller
gives you access to all the WindowC stuff, but how do you refer back
to Controller and its instance variables windowA and windowB?
I realize this must have a super simple answer, but I have hunted
around and found nothing in the non-doc context. Thanks.
_______________________________________________
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