TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.