0

Is it possible to use objective c to signal for application to close?

Regards,

Toby

August
  • 12,139
  • 3
  • 29
  • 30
TonyNeallon
  • 6,607
  • 12
  • 42
  • 49
  • possible duplicate of [Proper way to exit iPhone application?](http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application) – dbr Aug 22 '10 at 08:05
  • Duplicate of http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application – Chris Lundie Feb 12 '09 at 17:28

4 Answers4

6

You're not supposed to close an iPhone application. You're supposed to wait for the OS to signal to you that the user has gone elsewhere. Read the Human Interface Guidelines.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
2

On the iPhone, apps do not quit unless the user touches the Home button on the phone.

So even if there is some valid reason that your app cannot continue, you should not quit. Just put up an alert explaining why you can't do anything - e.g. "Sorry, this application needs to be connected to the internet. Please try again when you have coverage."

Then the user can read the alert, and press the home button to quit in the usual way. If the application quits on its own, it looks as though it has crashed.

Jane Sales
  • 13,526
  • 3
  • 52
  • 57
0

Having your application quit on its own or through user input on the screen is strongly discouraged by Apple. As it has been mentioned you can use exit(0) to force it, but if your app is headed for the App store expect a rejection. I'm not sure on the process of enterprise distribution of iPhone applications so I don't know what issues would occur there.

Covar
  • 901
  • 1
  • 7
  • 15
0

Previous commenter is right, but there may be cases where you want a "quit" button in your app. Just call exit(0) to quit the app.

  • thanks man. I had to be able to exit application in a reset app scenario. – TonyNeallon Feb 12 '09 at 13:12
  • 3
    Actually, there are NO cases where you'd want a Quit button in your app. The big "Home" button at the bottom of the device serves as the Quit button for EVERY app. – August Feb 12 '09 at 14:34
  • 3
    Afraid not in this scenario. Client wants , Client gets – TonyNeallon Feb 12 '09 at 17:52
  • 3
    I'd try to change the client's mind. In addition to it being a bad idea, it's highly possible that Apple will reject the app based on it's "non-adherence to the HIG," and it will end up looking like your fault. – August Feb 12 '09 at 21:32
  • Another option is to tell them this outright and formally identify this as a risk. That way they can't blame you later. Strangely enough, there are applications on the App Store which do have quit buttons. – Plumenator Sep 01 '10 at 15:32
  • If you are interested in submitting your app to the app store, it will be rejected if you use exit(0) – memmons Sep 23 '11 at 19:25