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      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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.