Re: creating a window
Re: creating a window
- Subject: Re: creating a window
- From: Steve Woodward <email@hidden>
- Date: Mon, 24 Mar 2003 07:38:35 -0500
Here's what I do (which may not be the ideal [or right] way!):
Create a new nib in IB. Add controls to the window, etc.
Subclass NSWindowController. Call it something like
"MyWindowController".
I usually don't instantiate above class. I use the File's Owner to
connect all my outlets and actions.
Create the files for above controller and add them to the project.
back in PB:
Declare an instance of the controller class in your header file:
MyWindowController *controller;
In your implementation file check for the existence of the nib, if not
load it and call it's show window method:
{
if (controller == nil)
{
controller = [[MyWindowController alloc]
initWithWindowNibName:@"somenib"];
}
[controller showWindow:self];
}
Use the above code in whatever event you want...menu, button on another
window..
Lastly, you have to release the controller. I usually do this in the
controller's dealloc method:
-(void)dealloc
{
[controller release];
}
Again, the above may not be the best method, but it seems to work okay
for me. Good luck!
Steve W
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.