iOSApprentice Ch 32

I’m up to ch 32 in MyLocations.

The program compiles but has a fatal error in AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
   let tabController = window!.rootViewController as! UITabBarController
    Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

    
    if let tabViewControllers = tabController.viewControllers {
        let navController = tabViewControllers[0] as! UINavigationController
        let controller = navController.viewControllers.first as! CurrentLocationViewController
        controller.managedObjectContext = managedObjectContext
    }
    print(applicationDocumentsDirectory)
    return true
}

I defined window as

var window: UIWindow?

The book says nothing about how this type of error might arise, so it is not clear to me how I can fix it.

My code for all files up to that point is the same as the Final source code for Ch 32

This means that no data are stored in Core Data.

Any advice would be appreciated.

did you manage to solve it?

I am having the same issue

@skytek @saipurva Do you still have issues with this?