Disabling Backgrounding
We start with the exact opposite of enabling backgrounding: disabling it. If you think about it, there are many different "diversion" apps that don't need to support background suspension or processing. These are apps that you use and then quit. They don't need to hang around in your task manager afterward.
For example, consider the HelloNoun application in Hour 6, "Model-View-Controller Application Design." There's no reason that the user experience would be negatively affected if the application started from scratch each time you ran it. To implement this change in the project, follow these steps:
- Open the project in which you want to disable backgrounding (such as HelloNoun).
- Open the project's plist file in the resources group (HelloNoun-Info.plist).
- Add an additional key to the property list, selecting Application Does Not Run in Background (UIApplicationExitsOnSuspend) from the Key pop-up menu.
- Click the check box beside the key, as shown in Figure 21.2.
Figure 21.2 Add the Application Does Not run in Background (UIApplication-ExitsOnSuspend) key to the project.
- Save the changes to the plist file.
Build and run the application on your iPhone or in the iPhone simulator. When you exit the application with the Home button, it will not be suspended, nor will not show in the task manager, and it will restart fresh when you launch it the next time.