I am pushing BViewController from A properly. B contains a webview that starts loading a page when viewDidLoad. I am getting a strange behavior when popping B to A,
- If webview finishes its load and then I execute popViewController (IBAction when touchUpInside on a toolbar button), popped to A so everything works perfectly.
- However, if I popViewController immediately before webview ends its load, app crashes due to exc_bad_access. why? view is already loaded!
I checked on both situations viewcontrollers that are on navigation stack. Both cases with same result, 2 same objects, no difference!
-(IBAction)goBackOrg:(id)sender{
NSArray *viewControllers = self.navigationController.viewControllers;
[[self navigationController] popViewControllerAnimated:NO];
}
and for previously pushing it, I am using
if(!self.BController){
self.BController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil anUrlDest:urlSocial];
}
[[self navigationController] pushViewController:self.BController animated:NO];
EXC_BAD_ACCESS occurs when you’re trying to access an object that has been deallocated.
So the following could be your problem: when you pop ViewController B, it is being unloaded. If the web view loading finishes after ViewController B is unloaded, some piece of callback code is getting executed that is trying to do something with your ViewController or its view (or similar).