If you have created a project on Xcode 11 and above you have noticed h new file created as SceneDelegate.swift. Let’s check below the difference between Scene Delegate and App Delegate.
If we create a new project before xcode 11, it will create some default files, as shown in below image.
From Xcode 11 onwards you might have noticed that along with the default files, it will create a new file as SceneDelegate.swift. As shown in the below image.
In apps prior to iOS 13, AppDelegate is the main entry point of the app, and in it, the application launches, and it handles app background and foreground states.
But from iOS 13 the responsibilities of app delegates have been split between AppDelegate and SceneDelegate.
That’s how the new multi-window support feature is introduced in iPad OS.
Even after iOS 13, the AppDelegate is still the main entry point of an application.
By default AppDelegate.swift have three main methods.
If your app is using scenes, your AppDelegate is no longer responsible for doing this.
Since your application can now have multiple windows or UISceneSessions active, it doesn’t make much sense to manage a single-window object in the AppDelegate
Whenever the application needs a new scene or window.
Whenever the user discards a scene by swiping it from the multitasking window or if discarded programmatically.
This method is called for every discarded scene shortly after the (_:didFinishLaunchingwithOptions:) method is called if the app isn’t running when the user discards the scene.
In addition to these methods, AppDelegate can still handle URLs, cache memory, app termination, push notifications, location services, and many more.
From iOS 13, SceneDelegate takes up some responsibilities from AppDelegate, particularly UIWindow in AppDelegate is now UIScene in SceneDelegate.
What is displaying on the screen is the responsibility of SceneDelegate. There are 6 default functions in SceneDelegate.
It will create a new window, sets the root view controller, and makes this window the key widow that will be displayed.
When the app becomes active for the first time or when transitions from background to foreground.
When the scene has moved from an inactive state to an active state.
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).
When the scene transitions from the foreground to the background.
While releasing the scene by the system.
The scene may re-connect later, as its session was not necessarily discarded (see
Hope the difference between Scene Delegate and App Delegate is clear now, if you still have any doubt or query you can let me know over the comment section.
Thanks for reading 🙂
Be the first to comment.