UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Swift on Sundays: Friendzone - AppDelegate or SceneDelegate?

Forums > Books

Hi,

I've been following the FriendZone chapter in Swift on Sundays, but haven't been able to get the coordinator working. I think it is due to the code to create the coordinator, which the book says to add to the willConnectTo method of SceneDelegate.swift. I took a look at the GitHub repository for this app to see where I was going wrong, and this doesn't have a SceneDelegate.swift, and instead the code is in AppDelegate.swift. I also tried removing SceneDelegate.swift from my project and putting the logic in AppDelegate, but that didn't work either. So I'd really just like to know why the difference between the GitHub repo and the book, and which is correct.

4      

The github repository was last updated 16 months ago, which is prior to WWDC19 introducing the new SceneDelegate class and way of doing things. The book, however, was last updated in Feb 2020 and therefore includes SceneDelegate and the new method.

5      

I found the solutiom by looking at someone else's version in GitHub. It seems that in SceneDelegate, instead of:

window = UIWindow(frame: UIScreen.main.bounds)

I should be doing:

guard let windowScene = (scene as? UIWindowScene) else { return } // this line already there ... window = UIWindow(windowScene: windowScene)

6      

Thanks for posting that solution, I was having the same problem!

4      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.