UISceneDelegate: Managing Your App's UI Instances

Think of SceneDelegate as the lifecycle manager for a single window of your app's UI. It's essential for multi-window iPad apps, handling when a scene connects, disconnects, or changes state.
Why it exists
Before iOS 13, the AppDelegate managed both the app's process lifecycle and its single UI window. To support multiple windows on iPadOS and macOS, Apple needed to separate the concept of the app's process from the lifecycle of its UI. UISceneDelegate was created to manage a single UI instance, or "scene," allowing an app to have several running concurrently.
The mental model
Think of AppDelegate as the theater owner, responsible for opening and closing the entire building (the app process). UISceneDelegate is the stage manager for one specific play (a UIWindowScene) within that theater. The stage manager handles when the curtain rises (sceneWillEnterForeground), when the lights dim for intermission (sceneDidEnterBackground), and when that specific play is over for the night (sceneDidDisconnect). An app can have multiple plays running at once, each with its own stage manager.
How it works
When your app needs to show a new UI instance, the system creates a UISceneSession object. For each session, UIKit creates a corresponding UIScene (like a UIWindowScene) and attaches your custom UISceneDelegate to it. Your delegate then receives callbacks for lifecycle events. The most critical method is scene(_:willConnectTo:options:), where you are given the scene object. Here, you must create a UIWindow, assign it a rootViewController, and make it visible. Other methods like sceneDidBecomeActive, sceneWillResignActive, and sceneDidEnterBackground allow you to respond to focus and visibility changes for that specific scene.
When to use it
You use UISceneDelegate in any iOS 13+ app that adopts the scene-based lifecycle, which is the default for all new projects. It is the correct place to configure your UI windows and respond to UI-specific state changes, especially if you want to support features like multiple windows on iPadOS or Split View.
When not to use it
If you are maintaining a legacy application that has explicitly opted out of the scene-based lifecycle (by removing the UIApplicationSceneManifest key from its Info.plist), you would continue to manage the UI window from the AppDelegate. For any new development, however, using the scene-based approach with UISceneDelegate is standard practice.
One canonical example
A typical implementation of the primary setup method, scene(_:willConnectTo:options:), involves a few key steps. First, you safely unwrap the scene as a UIWindowScene: guard let windowScene = (scene as? UIWindowScene) else { return }. Next, you initialize a UIWindow with that scene: let window = UIWindow(windowScene: windowScene). Then, you set its content: window.rootViewController = MainViewController(). Finally, you store a reference to the window and make it visible: self.window = window; window.makeKeyAndVisible().
Interview question
In iOS 13 and later, what is the fundamental role of UISceneDelegate in an application's architecture?
- a.To handle the lifecycle and state changes for a single UI instance, such as a window or scene.Correct
- b.To provide a centralized mechanism for managing user authentication and authorization flows.
- c.To facilitate communication between different app extensions and the main application target.
- d.To manage the entire application's process lifecycle, including background tasks and memory warnings.
Why? this is the answer
The card states UISceneDelegate is the "lifecycle manager for a single window of your app's UI" and was created "to manage a single UI instance." Option D describes the role of AppDelegate for the overall app process, not UISceneDelegate.
Just read this? Test yourself on what you have been reading.
Read the original → developer.apple.com
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on ios — each one lists the topics its interview covers.
See open roles