The first controller of my app has an avplayer, so i implemented observers which are set on viewWillAppear and are removed on viewDidDisappear.
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
addObservers()
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
avQueuePlayer.pause()
// remove observers
NSNotificationCenter.defaultCenter().removeObserver(self, name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIApplicationDidEnterBackgroundNotification, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIApplicationWillEnterForegroundNotification, object: nil)
}
When i receive a deeplink i create a new navigation stack and i then replace the current navigation controller stack with the new one :
navigationVC.viewControllers = newNavigationVC.viewControllers
Instead of loading properly the new controller (which is happening properly if i remove the code for the observers), the app crashes with :
libc++abi.dylib: terminating with uncaught exception of type NSException
I have no clue of what is happening since xcode is not giving me any indication and the trace is in assembly so it is not helping either.
Could someone point me to the proper direction to debug this?