• 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
what are the scenarios for an app to be terminated?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

what are the scenarios for an app to be terminated?


  • Subject: what are the scenarios for an app to be terminated?
  • From: eveningnick eveningnick <email@hidden>
  • Date: Wed, 6 Oct 2010 23:13:07 +0400

Hello!
What are all the scenarios for terminating the Cocoa application, and
can i catch the moment of quitting and do some "before quit" actions?
I am writing a "naked" cocoa application (basically for myself, to
understand what happens under the hood). So, instead of calling
NsApplicationMain, i do the following:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApplication *app = [NSApplication sharedApplication];

MyClass *myobject = [[[MyClass alloc] init] autorelease];

[app run];
[pool drain]; //or release
return 0;

Now i am wondering, how can i correctly "release" myobject (i.e. make
its -dealloc called) in as more "quitting scenarios" as possible - for
example, by clicking "with the right mouse button" app's icon on dock
and selecting "quit" there, by pressing Ctrl+C in terminal, by sending
kill signal...
I guess i should intercept some events from the main event loop, but
my superficial knowledge of "under-the-hood-things" don't let me to
understand what exactly should i do :)
How is it done in Cocoa framework by NSApplicationMain?
And what is the right way to terminate application, so it would
release all its allocated objects? Maybe it's a wrong way to use
-dealloc also as a destructor (like i did in C++) - where i save
config file? what is the right way?
Thanks for the answers
_______________________________________________

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

  • Follow-Ups:
    • Re: what are the scenarios for an app to be terminated?
      • From: Conrad Shultz <email@hidden>
    • Re: what are the scenarios for an app to be terminated?
      • From: Jack Nutting <email@hidden>
    • Re: what are the scenarios for an app to be terminated?
      • From: Seth Willits <email@hidden>
  • Prev by Date: Re: Let the runloop process its queue during a long operation
  • Next by Date: Re: what are the scenarios for an app to be terminated?
  • Previous by thread: NanoStore has moved to Google Code
  • Next by thread: Re: what are the scenarios for an app to be terminated?
  • Index(es):
    • Date
    • Thread