• 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: dealloc not beeing called... why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dealloc not beeing called... why?


  • Subject: Re: dealloc not beeing called... why?
  • From: James DiPalma <email@hidden>
  • Date: Tue, 9 Jul 2002 15:18:17 -0400

On Tuesday, July 9, 2002, at 10:34 AM, Development wrote:
OK, but I thought, the OS would care about the deallocation of the object. It has the -dealloc method already built-in and whoever created the instance of my subclasses NSObject after NIB load has to call this -dealloc method eventually, no?!

No. Nib files present a special sort of problem to developers. Top level objects leave nib loading with a retain count of 1 (it goes: init, retain, retain, autorelease, autorelease).

When NSWindowControllers load nib files, they will autorelease all top level objects when their window closes. I don't think that NSApplication does what NSWindowController does to release top level objects when NSApplications quit. Maybe it should, but how many applications would raise exceptions when quiting if this behavior changed?

If not, what's the right time and where's the right place to call the objects -dealloc method, i.e. is there a recommended way to do this? I have to do some clean up before quitting the app...

I think calling dealloc directly is not recommended. Try applicationWillTerminate:, NSApplicationWillTerminateNotification (both already suggested) or maybe override NSApplication's dealloc method.


-jim
_______________________________________________
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.

  • Follow-Ups:
    • RE: dealloc not beeing called... why?
      • From: "Jonathan E. Jackel" <email@hidden>
References: 
 >Re: dealloc not beeing called... why? (From: Development <email@hidden>)

  • Prev by Date: NSUserDefaults, NSArgumentDomain
  • Next by Date: Re: Non-standard Cocoa RTF Unicode encoding?
  • Previous by thread: Re: dealloc not beeing called... why?
  • Next by thread: RE: dealloc not beeing called... why?
  • Index(es):
    • Date
    • Thread