Explain iOS App Launch Cycle? | iOS Interview Question | iOS Programmer Guide

,
When your app is launched, it moves from the not running state to the active or background state, transitioning briefly through the inactive state. As part of the launch cycle, the system creates a process and main thread for your app and calls your app’s main function on that main thread. The default main function that comes with your Xcode project promptly hands control over to the UIKit framework, which does most of the work in initializing your app and preparing it to run.
Below figure shows the sequence of events that occurs when an app is launched into the foreground, including the app delegate methods that are called.
Figure 1  Launching an app into the foreground
Application life cycle
If your app is launched into the background instead—usually to handle some type of background event—the launch cycle changes slightly to the one shown in Figure 3-3. The main difference is that instead of your app being made active, it enters the background state to handle the event and then is suspended shortly afterward. When launching into the background, the system still loads your app’s user interface files but it does not display the app’s window.
Figure 2  Launching an app into the background
To determine whether your app is launching into the foreground or background, check the applicationState property of the shared UIApplication object in yourapplication:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: delegate method. When the app is launched into the foreground, this property contains the value UIApplicationStateInactive. When the app is launched into the background, the property contains the valueUIApplicationStateBackground instead. You can use this difference to adjust the launch-time behavior of your delegate methods accordingly.