Life cycle of iOS/iPadOS application

Vikas Kore
2 min readMar 24, 2021
https://sphera.com

You might noticed that project created on Xcode 11(iOS 13) and above a new file is created named as SceneDelegate.swift, let briefly understand what they do and when they called.

What is difference between AppDelegate and SceneDelegate

AppDelegate is responsible for handling application-level events, like app launch and the SceneDelegate is responsible for scene lifecycle events like scene creation, destruction and state restoration of a UISceneSession.

Arranged according to the call sequence:

willFinishLaunchingWithOptions

Apps first method called on launching

didFinishLaunchingWithOptions

App launched. Override point for customization after application launch.
i.e. initialization of entry point

configurationForConnecting

Called when a new scene session is being created. Use this method to select a configuration to create the new scene with

willConnectTo

Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
If using a storyboard, the `window` property will automatically be initialized and attached to the scene.

sceneWillEnterForeground

Called as the scene transitions from the background to the foreground. Use this method to undo the changes made on entering the background.
Always call when relaunch the app, when background to foreground transition.

sceneDidBecomeActive

Called when the scene has moved from an inactive state to an active state. Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
If you had/End a phone/skype etc call after that this method call.

sceneWillResignActive

Called when the scene will move from an active state to an inactive state.
This may occur due to temporary interruptions (ex. an incoming phone call).

sceneDidEnterBackground

Called as the scene transitions from the foreground to the background. Use this method to save data, release shared resources, and store enough scene-specific state information. To restore the scene back to its current state.

Keep in mind that these scenes are designed to work independently from each other. So, your application no longer moves to the background, but instead individual scenes do, the user might move one to the background while keeping another open. Thanks you.

sceneDidDisconnect

Called as the scene is being released by the system. This occurs shortly after the scene enters the background, or when its session is discarded. Release any resources associated with this scene that can be re-created the next time the scene connects.

applicationWillTerminate

If your kill the application

applicationDidReceiveMemoryWarning

Suspends app if any memory issue.

Thank you, Happy coding!

--

--