16.0. Introduction
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.
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 applicationWillEnterForeground: delegate
message.
In addition to these delegate messages, iOS also sends notifications
to the running application when it transitions the application to the
background and from the background to the foreground. The notification
that gets sent when the application is moved to the
background is UIApplicationDidEnterBackgroundNotification, and the notification that gets sent when an application transitions from the background to the foreground ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access