• 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
instantiateNibWithOwner:topLevelObjects: usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

instantiateNibWithOwner:topLevelObjects: usage


  • Subject: instantiateNibWithOwner:topLevelObjects: usage
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 30 Nov 2005 16:06:36 -0600

I've decided to take a different approach with my nib handling for my kiosk-based apps.

Basically, I have many nibs that each contains a window and sometimes other objects (instances of models mostly). I do not, however, use NSWindowController (or a subclass) as the controller (owner). When the nib is loaded, I grab the contentView of the window in the nib and set that as the content view of my app's main window.

I'm looking to use the instantiateNibWithOwner:topLevelObjects: API to provide a cleaner solution in cleaning up top-level objects. I've searched various archives, but found no real good examples on its usage. Many samples just pass in nil for topLevelObjects and thus do not do any cleanup of the top-level objects.

I think that a typical usage of the API would be like this (let's assume this code is in an initXXX method of the controller):

NSArray* theTopLevelObjects = nil;
[theNib instantiateNibWithOwner:self topLevelObjects:&theTopLevelObjects];
[self setTopLevelObjects:theTopLevelObjects];


I would assume that in the controller's dealloc, I'd have this:

- (void)dealloc
{
    NSArray* theTopLevelObjects = [self topLevelObjects];

// iterate over all items in the array and send them a release message
// remove all objects in the array (which should then reduce the retain count to 0 of the top-level-objects)
// release array


    [super dealloc];
}

Is that it?

Some of google's hits shows that Uli's UKProgressPanel used to use this API. Although, it was using the string @"NSTopLevelObjects" which may or may not be the actual value of the global NSNibTopLevelObjects.

Uli, did you rip out that code because it was problematic, or for other reasons?

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Question about autosaveTableColumns
  • Next by Date: Re: Question about autosaveTableColumns
  • Previous by thread: Re: Question about autosaveTableColumns
  • Next by thread: Help on subclassing
  • Index(es):
    • Date
    • Thread