Have been working for a long time trying to find the fix to my crash. Not sure if it's a fundamental design flaw on my part or something that can be fixed easily.
My app has a NavigationController embedded in a TabBarController. When I modally present a view from the root view controller of the NavigationController, it is presented and dismissed without any problem.
However, after i navigate forward in the navigation stack from the root ViewController of the NavigationController pushing other Controllers and then back to the root ViewController, I try the modally presentation again. This time it presents fine but when I dismiss it my app crashes with a EXC_BAD_ACCESS error.
After sometime debugging I found that when the modally presented ViewController is dismissed it is trying to access a ViewController in the navigation Heiarchy that has already been dismissed and thus the crash. Despite the fact that it was presented from the Root ViewController of the Navigation Stack.
It is causing me a lot of grief and wondering if anybody has come across something similar. Any help will be greatly appreciated. Thanks in advance.
Here is the presentation which occurs inside an AlertController Block:
let createNewMemoAction = UIAlertAction(title: "Create New Memo", style: .Default) { (action: UIAlertAction!) -> Void in
self.performSegueWithIdentifier("Segue To Create New Memo", sender: nil)
}
I am using an unwind to dismiss the viewController. I have tried dismissing with the following code with the same error:
@IBAction func cancelButtonPressed(sender: UIBarButtonItem) {
dismissViewControllerAnimated(true, completion: nil)
}
Thanks