I want to use Coordinator in my Swift project by using the file Navigator(), but I need to pass a UINavigationController inside to navigator.show().
The problem is that XCode shows this error:
Fatal Error: Unexpectedly found nil while unwrapping an Optional value in window!
AppDelegate
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow!
let navigator = Navigator()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let feedNavigation = window!.rootViewController! as! UINavigationController
navigator.show(segue: .listBeer, sender: feedNavigation)
return true
}
}
How can I pass this window.rootViewController! as! UINavigationController as a non-Optional value?