Re: Creating new instances of an IB object
Re: Creating new instances of an IB object
- Subject: Re: Creating new instances of an IB object
- From: "Alastair J.Houghton" <email@hidden>
- Date: Thu, 14 Aug 2003 14:15:40 +0100
On Thursday, August 14, 2003, at 11:22 am, John Lombardo wrote:
What is the recommended way to create new instances of an NSWindow
from a
Nib? Is it something along the lines of...
NSWindow newWindow = [[[NSWindow alloc] init] autorelease];
newWindow = windowFromNib;
...or is this just spaz?
Yep, it's spaz ;-)
You don't "create new instances of an NSWindow from a Nib" so much as
load existing instances of objects (including NSWindows) stored in the
.nib; if you want multiple instances of a particular set of objects,
you can just load the .nib multiple times using NSBundle's
-loadNibNamed:owner: method.
For example,
[[NSBundle mainBundle] loadNibNamed:@"MyWindow" owner:ownerOfMyWindow];
will load all of the objects stored in the .nib file "MyWindow.nib",
setting "File's Owner" to the object referred to by ownerOfMyWindow,
and sending an -awakeFromNib message to any of the loaded objects that
supports it.
Kind regards,
Alastair.
_______________________________________________
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.