How do I tell my application to close?

0 votes
asked Oct 28, 2008 by lounges

I have just discovered the nifty unhandled exception handler for cocoa-touch.

Now that I can gracefully notify the user about any unhandled exceptions that might crash my application, I'd like to shut down my application after notifying the user that a crash has occured.

Does anyone know how to shut down an application programmatically?

3 Answers

0 votes
answered Oct 28, 2008 by noah-witherspoon

You can call [[UIApplication sharedApplication] terminate]; - that won't build the screenshot Springboard uses to animate the application's exit, though, so the screen will just go black until the icons move in. There doesn't seem to be a published way to do this; the UIApplication header doesn't even mention the -terminate method, so you may just not be meant to do it at all.

0 votes
answered Oct 28, 2008 by chris-lundie

Apple's documentation says there is no "normal" way to shut down. In your case - an unhandled exception - immediate termination makes sense anyway.

0 votes
answered Oct 28, 2008 by rich
exit(0);

will do the trick...

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...