Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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 is my thread with a solution. It does actually work anywhere. You can code around the compiler warning easily using performSelector:
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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

macrumors 6502a
Original poster
Mar 13, 2008
989
0
Ok, thanks. It wasn't a big deal anyways, I just like having an exit button in my main menu.
Nate
 

SqueegyX

macrumors regular
Mar 24, 2008
108
1
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.