How to terminate iPhone application from code

Today i had to terminate an application, if certain launch conditions where not met (settings not filled out more specifically). I started out searching for information regarding UIApplication, but it turned out that a simple C call does the job: exit(0);

Update: As is pointed out in comments, there seem to be some content as to wether explicitly exiting an application will result in failure to pass the Apple AppStore aproval process.

In my case i was building a pure online app. If no connection could be established on startup, the user would be presented the option to retry or cancel. Cancel would result in the app exiting. Pretty rutine behavior, but I guess I could just remove the cancel button and leave it up to the user to use the hardware button.

In light of the new information then, the proper recommendation has to be do not terminate apps explicitly.

Tags: , , , , , , , , ,

2 Responses to “How to terminate iPhone application from code”

  1. TheKnickerKicker Says:

    No it doesn’t. See

  2. Olav Rask Says:

    Well.. ..technically it does – but please read my update 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: