我推着一個視圖控制器到我的導航控制器的堆棧從我TableViewController的didSelectRowAtIndexPath方法方法中像這樣:這是爲什麼過度釋放?的UINavigationController/UITableView的
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
MyObject *myO = (MyObject *)[appDelegate.myOs objectAtIndex:indexPath.row];
myViewController.amount = myO.amount;
[self.navigationController pushViewController:myViewController animated:YES];
[myViewController release];
如果我去掉最後一行,然後應用程序崩潰時返回一個錯誤:
-[CALayer release]: message sent to deallocated instance 0xd4f860
進一步挖掘我發現崩潰可以進一步縮小到在MyViewController的dealoc方法中調用[super dealoc]。通過取消註釋「[super dealoc]」,我們不會崩潰。
我無法進一步縮小這一點。 「超級」將是UIViewController類,我不能進一步調查dealoc方法......我可以嗎?也許有一種方法可以看到0xd4f860究竟是指向了什麼,但我不知道如何?有任何想法嗎?
您是否在任何地方發佈myViewController.view? – 2009-07-22 19:40:26