- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to exit iPhone application gracefully?
There are times we would like to close our application due to some reason, for example if there is no internet connection and you’d like to kill the app, or any other reason according to the application. Though apple prefers not quitting the application, hence it is not supported in any of the applications.
The only way to logically kill an iOS application is by pressing the home button. As soon as the home button is pressed, and the application exits the memory is freed up and cleaned.
Still there are other ways to quit an application.
exit − this command may be used to exit the application on required events, it can be used like exit(0)
Apart from exit, we may also use, [[NSThread mainThread] exit];
Or we can manually call the delegate method, - (void)applicationWillTerminate:(UIApplication *)application
But, as we saw earlier apple does not provide any perfect way of quitting applications using above methods, it’s best to show user an alert and ask them to press the home button to quit the application.
Kickstart Your Career
Get certified by completing the courseGet Started