• 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: App startup/shutdown hooks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >App startup/shutdown hooks (From: Neil Baylis <email@hidden>)

  • Prev by Date: App startup/shutdown hooks
  • Next by Date: Bindings "Prepares content" to automatically initialize some fields?
  • Previous by thread: App startup/shutdown hooks
  • Next by thread: Re: App startup/shutdown hooks
  • Index(es):
    • Date
    • Thread