也许我已经看了太久了;)我的应用程序有一个NavigationController和几个ViewController。从ViewControllers的两个层次之一(mainViewController),从rootViewController加载,下面是我的代码。在PushViewController到dataViewController并返回(例如,按下后退按钮)之后,应用崩溃。
dataViewController加载就很好,但是当轻按navigationController的后退按钮时,应用程序崩溃并出现Object Exception。如果我删除:
[dataViewController release];
该应用程序运行正常。这很奇怪,因为dataViewController是用相同的方法初始化的。
有任何想法吗?
- (void) locationPage
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"NotifyRemoveMap" object:nil];
MyAppDelegate *app = [[UIApplication sharedApplication] delegate];
UINavigationController *navigation = app.navigationCantroller;
[navigation popToRootViewControllerAnimated:NO];
DataViewController *dataViewController = [[DataViewController alloc] initWithNibName:@"DataView" bundle:nil];
[dataViewController setCategoryId:category];
MyLanguage *lang = app.lang;
Mylocation *location = [lang locationForCategoryId:category];
dataViewController.title = location.name;
NSArray *locationArray = [lang locations];
dataViewController.locations = locationArray;
[navigation pushViewController:dataViewController animated:YES];
[dataViewController release]; // With this removed, app doesn't crash
}
最佳答案
甚至都没看过您的帖子。如果是Exec-Bad-Access,那么我有两个词供您参考:
启用NSZombies。
请点击以下链接:(它说明了解决任何不良访问问题所需了解的一切)
Phone Memory Debug with NSZombie and Instruments
干杯!