• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating new instances of an IB object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Creating new instances of an IB object (From: John Lombardo <email@hidden>)

  • Prev by Date: Re: Tons of fun w/NSComboBox
  • Next by Date: Re: Getting the name of a class
  • Previous by thread: Creating new instances of an IB object
  • Next by thread: French Localization and Accents
  • Index(es):
    • Date
    • Thread