Understand State Transitions

The UIApplication object provides the application-wide control and coordination for an iOS application. It is responsible for handling the initial routing of incoming user events (touches, for example) as well as dispatching action messages from control objects (such as buttons) to the appropriate target objects. The application object sends messages to its Application Delegate to allow you to respond, in an application-unique way, when your application is executing, to things such as application launch; low-memory warnings; and state transitions, such as moving into background and back into foreground.

You should implement the following UIAppDelegate methods in your application:

Method

What You Do with It

application:did FinishLaunchingWith Options:

In this method, do what you need to do to initialize your application after it’s launched.

applicationWill ResignActive:

This message is sent when the application is about to move from active to inactive state. Use this method to do things such as pause ongoing tasks and anything based on a timer (such as a game). Using this method doesn’t mean that you will be entering background, but it does mean that your application won’t be executing.

applicationDidEnter Background:

This message is sent when your application is going to be entering background. At this point, you need to assume that your application may eventually be terminated without warning, so save user data, invalidate ...

Get iPad Application Development For Dummies, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.