O'Reilly logo

Programming iOS 4 by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Application Lifetime Events

As I’ve already mentioned, events mark certain important stages in the overall lifetime of your application. These events can arrive either as messages to the app delegate (if you implement the appropriate methods) or as notifications to any object (if that object registers for those notifications).

In the old days, before iOS 4, this suite of events was pretty simple:

applicationDidFinishLaunching:
The app has started up. This, as we have already seen many times, is the earliest opportunity for your code to configure the interface by showing the app’s window. (For reasons that we haven’t yet discussed, it is now better for your app delegate to implement application:didFinishLaunchingWithOptions: instead.)
applicationDidBecomeActive:
The app has started up; received after applicationDidFinishLaunching:. Also received after the end of the situation that caused the app delegate to receive applicationWillResignActive:.
applicationWillResignActive:
Something has blocked the app’s interface. The most common cause is that the screen has been locked. An alert from outside your app could also cause this event.
applicationWillTerminate:
The app is about to quit. This is your last signal to preserve state (typically, by storing information with NSUserDefaults) and perform other final cleanup tasks.

Starting with iOS 4, however, apps operate in a multitasking environment. The Home button doesn’t terminate your app; it suspends it. This means that your app ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required