views:

101

answers:

2

I have found many apps where you can press a button or something similar and the application will terminate and bring you back to the home screen. How would I do this?

A: 

from http://www.iphonedevsdk.com/forum/iphone-sdk-development/6928-exit-application.html

[[UIApplication sharedApplication] terminateWithSuccess];
John Boker
That is not a public API method.
St3fan
the question didnt ask for a public api method.
John Boker
Did so ask for public - what is iPhone sdk 3.0? if not public.
Aran Mulholland
+1  A: 

exit(0);

this can exit the app .

again, the best way I think will be like as follows:

    //@step invoke the normal routine applicationWillTerminate
if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(applicationWillTerminate:)]) 
{
    [[UIApplication sharedApplication].delegate performSelector:@selector(applicationWillTerminate:) withObject:[UIApplication sharedApplication]];
}
//@step force quite app
kill(getpid(), SIGINT); 

I got it from other post on the overflow :D

Robin