what are the scenarios for an app to be terminated?
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