views:

1814

answers:

6

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

Regards,

Toby

+6  A: 

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
+1  A: 

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
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
Afraid not in this scenario. Client wants , Client gets
TonyNeallon
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
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
+2  A: 

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
A: 

What if my app has a major failure and I want to exit it and make the user re-run it later?

Gloria
Please don't post your questions as answers. Either add a Comment or Ask Question. The answer to this particular question is given by Jane Sales above in the second paragraph.
DyingCactus
A: 

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