• 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: Is dealloc called for an object instantiated with IB?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is dealloc called for an object instantiated with IB?


  • Subject: Re: Is dealloc called for an object instantiated with IB?
  • From: Sean Murphy <email@hidden>
  • Date: Sat, 29 Sep 2007 10:15:43 -0400


On Sep 29, 2007, at 8:38 AM, Bob Ueland wrote:

In Hillegass book chapter 4, there is a class called AppController instantiated with IB. In the file AppController.m there is the following method:

- (void)dealloc
{
    NSLog(@"dealloc");
    [speechSynth release];
    [super dealloc];
}
@end


However when I run the application and quit it, I never see the text "dealloc" appear in the log window. Does this mean that this method is never called?

Hey Bob,

At first glance, the memory responsibility of Nib objects can be confusing, but here are some good explanations from the ADC:

"The File’s Owner of an application’s main nib file (which contains the application menu and possibly other items) is the global application object NSApp. However, when a Cocoa application terminates, top level objects in the main nib do not automatically get dealloc messages just because NSApp is being deallocated. In other words, even in the main nib file, you have to manage the memory of top-level objects."

"With single-window applications, objects in the main nib file persist through the runtime life of the application and are released when the application terminates; however, dealloc is not guaranteed to be automatically invoked on objects from the main nib file when an application terminates."

If you need more fine-grained control about the disposal of your Nib's top level objects (especially if you're loading multiple instances of a given nib and associated controller objects or you specifically require that dealloc be executed), look into using NSWindowController to manage everything for you.

See 'Memory Management of Nib Objects' for more information: <http:// developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/ Articles/MemMgmtNibObjects.html#//apple_ref/doc/uid/TP40004998>

- Sean_______________________________________________

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


References: 
 >Is dealloc called for an object instantiated with IB? (From: Bob Ueland <email@hidden>)

  • Prev by Date: Re: NSTokenfield: Drag and Drop / Autocompletion
  • Next by Date: Re: Setting Breakpoints in XCode - Comically slow
  • Previous by thread: Re: Is dealloc called for an object instantiated with IB?
  • Next by thread: Re: NSTokenfield: Drag and Drop / Autocompletion
  • Index(es):
    • Date
    • Thread