PDA

View Full Version : manually quit app?




liptonlover
Oct 23, 2008, 05:25 PM
How can I manually close my app? I've looked under UIApplication and UIResponder but can't find a method for this and I don't know where else to look.
Thanks, Nate



robbieduncan
Oct 23, 2008, 06:15 PM
Do a search. This has been asked multiple times, once by me where I answered my own question. In short: there is no supported way to do this and the iPhone HIG basically says not to do it. Assuming you want all the normal notifications to get sent/the app to shut down cleanly you can only do it via a non-public API.

Edit: Here (http://forums.macrumors.com/showthread.php?t=541486) is my thread with a solution. It does actually work anywhere. You can code around the compiler warning easily using performSelector:

firewood
Oct 23, 2008, 06:34 PM
The posix call exit() is available in the official SDK API's, but its use in not recommended by the HIG.


.

robbieduncan
Oct 23, 2008, 06:35 PM
The posix call exit() is available in the official SDK API's, but its use in not recommended by the HIG.

The only issue with that is that it does not fire the normal application quit notifications so your app might well not save it's state correctly. Of course you could call the save routines directly then call exit()...

liptonlover
Oct 23, 2008, 06:55 PM
Ok, thanks. It wasn't a big deal anyways, I just like having an exit button in my main menu.
Nate

SqueegyX
Oct 23, 2008, 07:08 PM
Ok, thanks. It wasn't a big deal anyways, I just like having an exit button in my main menu.
Nate

Your home button is the universal exit button. No need to duplicate it. I don't think I have ever seen an app with an exit button.