What is a SceneDelegate in Swift?

In short the SceneDelegate.swift file is there to help with the new multi-window support that was announced with iOS 13.

The UISceneDelegate protocol is used to manage the life cycle for one instance of your app. Apple gave a good example of this when showing multiple instances of their notes app in split screen alongside other apps at the WWDC keynote.

Think of SceneDelegate as a offshoot of the AppDelegate. The AppDelegate will still handle things like configuring the initial scenes and register for services like push notifications but now the AppDelegate will be sharing its responsibility of the apps life cycle with the SceneDelegate.

Things like state transition methods or life cycle methods that use to be handled in the AppDelegate, like “will enter foreground”, “will become active”, and “when it enters the background” are now handled in the SceneDelegate.

For a more indepth look into the SceneDelegate and all the changes to the AppDelegate I recommend reading this great article by Reinder de Vries. Reinder takes a deep dive look into how to get started using the SceneDelegate and what has changed in iOS 13.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s