# Chapter 32 - CoreData Unwrapping Optional Error

**URL:** <https://forums.kodeco.com/t/chapter-32-coredata-unwrapping-optional-error/122264>\
**Category:** iOS Apprentice\
**Created:** [October 9, 2020, 5:53pm UTC](https://forums.kodeco.com/t/chapter-32-coredata-unwrapping-optional-error/122264 "2020-10-09T17:53:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![landestoy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/landestoy/32/81494_2.png) [@landestoy](https://forums.kodeco.com/u/landestoy)\
**Post date:** [October 9, 2020, 5:53pm UTC](https://forums.kodeco.com/t/chapter-32-coredata-unwrapping-optional-error/122264/1 "2020-10-09T17:53:02Z")

</div>

Hi guys,

Pretty stuck on an unwrapping optional issue while trying to get App Delegate to pass the context along to the CurrentLocationViewController through application(:didFinishLaunchingWIthOptions). I’m running the latest xCode (11.7), and the creation of the CoreData files added more code than your tutorial suggests. Everything looks good and I’ve reviewed your finished sample project for Chapter 32 - but no luck. The Error is:  
**2020-10-09 13:29:02.546646-0400 MyLocations\_2020[5740:1113110] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file … AppDelegate.swift, line 19**

The code where the error is found:

**func** application( **\_** application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: **Any**]?) → Bool {

--------\> **let** tabController = window!.rootViewController **as**! UITabBarController \<------------

**if**  **let** tabViewControllers = tabController.viewControllers {

**let** navController = tabViewControllers[0] **as**! UINavigationController

**let** controller = navController.viewControllers.first **as**! CurrentLocationViewController

controller.managedObjectContext = managedObjectContext

}

print(applicationDocumentsDirectory)

listenForFatalCoreDataNotifications()

**return**  **true**

}

Please help 🙂  
Thank you,

Alandestoy

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [March 25, 2021, 9:53am UTC](https://forums.kodeco.com/t/chapter-32-coredata-unwrapping-optional-error/122264/2 "2021-03-25T09:53:02Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
