Passing the context from AppDelegate - Chapter 27 - Saving Locations

Hi everyone, i’m having an issue with an UIWindow variable. In the Page 642, i need to pass the NSManagedObject from the AppDelegate. First i declared window : UIWindow? as an optional. Then how it says in the book, i declared let tabController = window!.rootViewController as! UITabBarController. But in the debug console it shows me an error like this: Unexpectedly found nil while unwrapping an Optional value. I don’t understand why window is nil, either what exactly this window variable does. And if i have fisrt to assing any value to this window variable. I’m usign Xcode 11.3.
Thanks.

I have same problem with you. Waiting someone to answer also. I think it is because iOS13 has SceneDelegate working with AppDelegate.

It’s very weird. I tried the book code, here I leave the link for the download: https://store.raywenderlich.com/products/ios-apprentice-source-code. With that code it works for me correctly (use the final chapter 27) And in the AppDelegate I have the same code as the one in the book.

I found solution, you just move all code from AppDelegate to SceneDelegate.

@turon Do you still have issues with this?

@superkookai Glad you sorted it out!