This post is in response to a question on the iPhone Dev SDK forums about how to make your apps not run in the background now that multitasking has finally appeared on the iPhone.
Multi-tasking can be great, but it has added some complexity to programming on the iPhone. For many apps there really is no advantage. For instance, does the “That’s What She Said” button really need to stay in memory?
It’s some added complexity that programmers don’t need.. some of the more complex memory intensive apps will just exit anyways, and programming the app to suspend can be a highly complicated task.
Fortunately there is a simple way to make your iOS 4 apps terminate for real when the user taps the home button.
This is a simple process:
- Open your info.plist file
- Add The Key UIApplicationExitsOnSuspend or Select Application does not run in background
- Set the new key to YES or Fill in the tick box
Now your applicationwillterminate: method will be run when the user taps the home key, and your app will exit for real.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.
The resources we feel will appeal to our readers the most will be posted on the front page.