Lounges
Lounges

Reputation: 4664

How do I tell my application to close?

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?

Upvotes: 2

Views: 4069

Answers (3)

Rich
Rich

Reputation: 2903

exit(0);

will do the trick...

Upvotes: 2

Chris Lundie
Chris Lundie

Reputation: 6023

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

Upvotes: 0

Noah Witherspoon
Noah Witherspoon

Reputation: 57139

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.

Upvotes: 6

Related Questions