2012-03-26 79 views
0

我有一個有趣的問題,我似乎無法找出爲什麼它正在發生,可能是小東西,我俯瞰。NSZombie在didSelectRowAtIndexPath方法

我有一個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]; 

編輯:

事情我忘了提的是,在某些情況下,我推這個相同的類到navigationcontroller的一個又一個,但去的時候到WorkflowViewController,然後到下一個視圖控制器,然後再兩倍拋出異常

它只
+0

如果有什麼你做了新的ViewController強大的屬性,而不是一個方法伊娃。這會給你一個保證,它不會太早發佈。 – CodaFi 2012-03-26 20:59:22

+0

當您嘗試訪問已釋放的對象時,會發生EXC_BAD_ACCESS錯誤。您應該在用於回彈到原始視圖的方法上發佈代碼片段。你提到你至少推動了另一種觀點。也許你正在釋放那裏的對象? – Justin 2012-03-26 21:00:33

+0

你能告訴我們didSelectRowAtIndexPath方法嗎?只需粘貼你的整個回溯。要從終端了解更多關於錯誤的信息,請使用malloc_history。 – 2012-03-26 21:01:57

回答

0

爲了記憶和效率的緣故,讓所有的UIViewControllers強大的屬性(支持iVar)來保證它們在任何有用的地方保持足夠長的時間。

相關問題