我有一个有趣的问题,我似乎无法找出它为什么会发生,可能是我忽略的小事。
我有一个UITableView,在我的didselectrowatindex路径中,我导航到一个新视图,然后导航到下一个视图并弹出两个视图以返回到第一个,然后应用程序崩溃与EXC_BAD_ACCESS
所以我使用了乐器和NSZombie并在didselectrowatindexpath找到了malloc,但我不知道为什么
这是我的代码:
if([workflowswithdirectories count] == 0)
{
WorkflowViewController *aWorkFlow = [[WorkflowViewController alloc] init];
MenuObject *obj = [workflownames objectAtIndex:[indexPath row]];
aWorkFlow.heading = obj.name;
aWorkFlow.workId = obj.workflowid;
aWorkFlow.siteId = obj.siteid;
aWorkFlow.item = obj;
[self.navigationController pushViewController:aWorkFlow animated:YES];
}
else if([workflownames count] == 0)
{
WorkflowListViewController *work = [[WorkflowListViewController alloc] init];
work.siteId = self.siteId;
MenuObject *obj = [workflowswithdirectories objectAtIndex:[indexPath row]];
work.menu = obj.next;
work.heading = obj.name;
[self.navigationController pushViewController:work animated:YES];
}
else
{
if([indexPath section] == 0)
{
WorkflowListViewController *work = [[WorkflowListViewController alloc] init];
work.siteId = self.siteId;
MenuObject *obj = [workflowswithdirectories objectAtIndex:[indexPath row]];
work.menu = obj.next;
work.heading = obj.name;
[self.navigationController pushViewController:work animated:YES];
}
else
{
WorkflowViewController *aWorkFlow = [[WorkflowViewController alloc] init];
MenuObject *obj = [workflownames objectAtIndex:[indexPath row]];
aWorkFlow.heading = obj.name;
aWorkFlow.workId = obj.workflowid;
aWorkFlow.siteId = obj.siteid;
aWorkFlow.item = obj;
[self.navigationController pushViewController:aWorkFlow animated:YES]; //Malloc is on this line
}
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
编辑:
我忘记提到的是,在某些情况下,我将同一个类中的另一个推入导航控制器,但只有在转到WorkflowViewController然后再转到下一个viewcontroller然后返回两次才会抛出异常< / p>
答案 0 :(得分:0)
为了记忆和效率,让所有UIViewControllers都具有强大的属性(使用支持iVar),以确保它们能够保持足够长的时间以备有用的东西。