Multitasking enables background execution, which means the application can keep working as usual—running tasks, spawning new threads, listening for notifications, and reacting to events—but simply does not display anything on the screen or have any way to interact with the user. When the user presses the Home button on his device, which in previous versions of the iPhone and iPad would terminate the application, the application is now sent into the background.
An application running on an iOS version that supports multitasking is, by default, opted into background execution. If you link your application against iOS SDK 4.0 and later, you can opt out of background execution, as you will see in Recipe 12.10. If you do, your application will be terminated when the user presses the Home button, as before.
When our application moves to the background (such as when the
user presses the Home button) and then back to the foreground (when the
user selects the application again), various messages are sent by the
system and are expected to be received by an object we designate as our
application delegate. For instance, when our application is sent to the
background, our application delegate will receive the
applicationDidEnterBackground: method, and as
the application comes back to the foreground for the user, the
application delegate will receive the
In addition to these delegate messages, iOS also sends notifications to the ...