Have you tried exit(0)
?
Alternatively, [[NSThread mainThread] exit]
, although I have not tried that it seems like the more appropriate solution.
On the iPhone there is no concept of quitting an app. The only action that should cause an app to quit is touching the Home button on the phone, and that's not something developers have access to.
According to Apple, your app should not terminate on its own. Since the user did not hit the Home button, any return to the Home screen gives the user the impression that your app crashed. This is confusing, non-standard behavior and should be avoided.
After some tests, I can say the following:
- using the private interface :
[UIApplication sharedApplication]
will cause the app looking like it crashed, BUT it will call - (void)applicationWillTerminate:(UIApplication *)application
before doing so;
- using
exit(0);
will also terminate the application, but it will look "normal" (the springboard's icons appears like expected, with the zoom out effect), BUT it won't call the - (void)applicationWillTerminate:(UIApplication *)application
delegate method.
My advice:
- Manually call the
- (void)applicationWillTerminate:(UIApplication *)application
on the delegate.
- Call
exit(0);
.