Re: App startup/shutdown hooks
Re: App startup/shutdown hooks
- Subject: Re: App startup/shutdown hooks
- From: Tom Harrington <email@hidden>
- Date: Tue, 4 Oct 2005 09:36:36 -0600
On 10/4/05, Neil Baylis <email@hidden> wrote:
> Here's my main, generated by interface builder, with printouts added.
>
> int main(int argc, char *argv[])
> {
> int retval;
> printf("App starting\n");
> retval = NSApplicationMain(argc, (const char **) argv);
> printf("App exiting\n");
> return retval;
> }
>
> When I run it, the first printout prints fine, and the app runs as
> expected. The window comes up and works correctly. When the app exits,
> (by closing it from the gui) the second printf never prints. If I put
> a breakpoint there, it never hits. This is probably very basic, but..
> what's going on here?
NSApplication is exiting directly, probably by exit() or something similar.
> What is the correct way for me to execute some cleanup code when the
> application exits?
Ask NSApplication to tell you when the application is going to exit.
You can either set a class to be NSApplication's delegate, or else
register for the appropriate notifications. The NSApplication docs
will help here.
--
Tom Harrington
email@hidden
AIM: atomicbird1
_______________________________________________
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