John
John

Reputation: 10969

How can I close an iPad app in Objective-C?

I would like to close an iPad application as a result of clicking on a UIButton. However, I have not seen how to do this in the Apple documentation.

What call needs to be made to close an app?

Thanks.

Upvotes: 3

Views: 2875

Answers (4)

Yucel Bayram
Yucel Bayram

Reputation: 1663

It says:

Don’t Quit Programmatically

Never quit an iOS app programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your app from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the app malfunction is, you have two choices.

Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your app. It puts users in control, letting them decide whether they want to take corrective action and continue using your app or press the Home button and open a different app

If only some of your app's features are unavailable, display either a screen or an alert when people use the feature. Display the alert only when people try to access the feature that isn’t functioning.

Upvotes: 5

taskinoor
taskinoor

Reputation: 46027

You can call exit(0) to terminate the app. But Apple don't like this as this gives the user a feeling of sudden crash. If you still want to have an exit function (with a potential risk of rejection) then you should also send your app delegate the applicationWillTerminate message (if you have anything important there) before performing the exit.

Upvotes: 5

Stephen Darlington
Stephen Darlington

Reputation: 52565

The only way for a user to exit an application is by pressing the Home button. You can't do it in your app, at least not in a way that Apple would accept.

Upvotes: 3

Dmitry
Dmitry

Reputation: 1041

You can try to use command:

exit(0);

Upvotes: -1

Related Questions