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

App startup/shutdown hooks


  • Subject: App startup/shutdown hooks
  • From: Neil Baylis <email@hidden>
  • Date: Tue, 4 Oct 2005 08:21:10 -0700

I'm porting a unix command line app to be a Cocoa app. My program
opens a device (/dev/tty.usbserial) when it starts up, and closes it
when it exits. I haven't been able to figure out how to make this work
correctly when it's a Cocoa app.

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?

What is the correct way for me to execute some cleanup code when the
application exits?

Thanks,

Neil Baylis


--
http://www.pixpopuli.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: App startup/shutdown hooks
      • From: Damien Bobillot <email@hidden>
    • Re: App startup/shutdown hooks
      • From: Nick Zitzmann <email@hidden>
    • Re: App startup/shutdown hooks
      • From: Tom Harrington <email@hidden>
  • Prev by Date: Re: Crash within Cocoa with Guarded Malloc
  • Next by Date: Re: App startup/shutdown hooks
  • Previous by thread: Get the installed OS country code
  • Next by thread: Re: App startup/shutdown hooks
  • Index(es):
    • Date
    • Thread