• 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: NSApplication Terminate:self <-- doesn't trigger dealloc method.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSApplication Terminate:self <-- doesn't trigger dealloc method.


  • Subject: Re: NSApplication Terminate:self <-- doesn't trigger dealloc method.
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 17 May 2006 16:44:29 -0500


On May 17, 2006, at 4:30 PM, Frederick C. Lee wrote:

Greetings:
I have a [NSApp terminate:self]; method that I call within an Exception handler. I noticed that the resident dealloc method isn't fired.
Just to be safe, I would like the dealloc method to fire.


How do I trigger the resident dealloc method when I programmatically terminate the program?

If your dealloc is only going to release memory-based objects and do nothing else, then there's really no reason to call dealloc since the app is going away.


However, if your object is doing crucial cleanup tasks, you could refactor things a bit. Note that I'm now going to assume that the object in question can become a singleton and that your main app controller can hold a reference to that object. If so, you can release that singleton object from within applicationWillTerminate:

What I do for my singletons is to implement a cleanup_II class-based API. They are then all called from within applicationWillTerminate:

One could get a bit fancy and come up with a "cleanup" protocol and have the app controller maintain a container of objects implementing that protocol. Perhaps a "register" API could be used to build up the container. Then, you'll simply iterate through that container and call a well-known API to perform cleanup.

___________________________________________________________
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


  • Follow-Ups:
    • Re: NSApplication Terminate:self <-- doesn't trigger dealloc method.
      • From: Ricky Sharp <email@hidden>
References: 
 >NSApplication Terminate:self <-- doesn't trigger dealloc method. (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Re: programmatically determining if the machine is intel or not
  • Next by Date: Re: NSApplication Terminate:self <-- doesn't trigger dealloc method.
  • Previous by thread: Re: NSApplication Terminate:self <-- doesn't trigger dealloc method.
  • Next by thread: Re: NSApplication Terminate:self <-- doesn't trigger dealloc method.
  • Index(es):
    • Date
    • Thread