manually quit app?

Discussion in 'iOS Programming' started by liptonlover, Oct 23, 2008.

  1. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #1
    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
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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:
     
  3. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #3
    The posix call exit() is available in the official SDK API's, but its use in not recommended by the HIG.


    .
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    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()...
     
  5. liptonlover thread starter macrumors 6502a

    Joined:
    Mar 13, 2008
    #5
    Ok, thanks. It wasn't a big deal anyways, I just like having an exit button in my main menu.
    Nate
     
  6. SqueegyX macrumors regular

    Joined:
    Mar 24, 2008
    #6
    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.
     

Share This Page