The [super dealloc] in dealloc of UIViewController giving problem in iPad
I am working on an application where i am pushing one view controller on to a UINavigationController and releasing it immediately as the navigation controller retains it.When i am poping the view controller the dealloc
method is being called as expected but the problem is the app is getting crashed.If i observe in GDB by enabling NSZombie
its saying that -[MyViewController isKindOfClass:]: message sent to deallocated instance 0x6847a00
.If i remove [super dealloc]
from my view controller's dealloc
method its worki开发者_运维问答ng just fine.I have nothing else in dealloc method except [super dealloc].What could be the problem here, can any one please help.The code snippet is below:
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
myViewController.path = selectedPath; //very important to set path here
myViewController.parentViewController = self;
[self cleanBookshelf];
[self.navigationController pushViewController:myViewController animated:NO];
[myViewController release];
[indicatorView removeFromSuperview];
[loadingindicator stopAnimating];
and i am poping in one action method of myViewController as
-(IBAction)goBack:(UIButton*)sender{
[self.navigationController popViewControllerAnimated:YES];
}
Just guessing, but I suspect that the problem is with this line:
myViewController.parentViewController = self;
UIViewController's parentViewController
property is marked readonly
, and I'd take that as a strong message that you shouldn't mess with it.
精彩评论