Shared Initialization for AppDelegate and SceneDelegate
Useful!
I recently looked at some of my old articles. Specifically I took a look at deleting the Storyboard in order to start a new project this one.
I realised something that actually came up in a job interview a couple of years ago. If you wanted to support iOS versions prior to 13 you’d need to use AppDelegate
and for iOS 13 and later you’d need to use SceneDelegate
. How can we do this without unnecessarily repeating code?
I’ll explain in this very project.
Creating a new project
This is the normal routine. In Xcode choose `File>New>Project` and choose App.
The other options can be set to be the defaults.
Change the ViewController
We want to see if this code is working. I’ll simply set the background colour of the view controller to purple. For fun I’ll add the initilizer even though in this example…