diff --git a/Sources/UIPilot/UIPilot.swift b/Sources/UIPilot/UIPilot.swift index ea147c5..ec0944e 100644 --- a/Sources/UIPilot/UIPilot.swift +++ b/Sources/UIPilot/UIPilot.swift @@ -147,8 +147,12 @@ struct NavigationControllerHost: UIViewControllerRep } static func dismantleUIViewController(_ navigation: UINavigationController, coordinator: ()) { - navigation.viewControllers = [] - (navigation as! PopAwareUINavigationController).popHandler = nil + DispatchQueue.main.async { + navigation.viewControllers = [] + if let popAwareNav = navigation as? PopAwareUINavigationController { + popAwareNav.popHandler = nil + } + } } typealias UIViewControllerType = UINavigationController