find a strange code here I have a viewcontroller, it has an array with books, and click the cell, then push to a detailViewController, detailVC has a variable infoDict,
@property (nonatomic,retain) NSMutableDictionary * infoDict;
navigationController push
DetailViewController * tDVC = [[DetailViewController alloc] init];
tDVC.infoDict = infoDict;
[self.navigationController pushViewController:tDVC animated:YES];
[tDVC release];
tap the back button, pop back, and inside dealloc of DetailVC
-(void)dealloc
{
[super dealloc];
NSLog(@"before %d",infoDict.retainCount);
[infoDict release];
}
but when I tap back, in this dealloc app crashes randomly, EXC_BAD_ACCESS.
when move [super dealloc] to the bottom of dealloc, it seems back to normal. pls help me to understand this , many thanks
[super dealloc]
deallocates the object itself. If you typedealloc
and let Xcode autocomplete, you get this:Meaning you should release objects and properties before you call
[super dealloc]