2011-02-15 197 views
0

我做了一個應用程序。在這個應用程序中,我已經加載一個tableView和一些文本,並選擇tableview中的行加載另一個tableview,但在選擇行時應用程序崩潰的設備。這一切在模擬器中都很好。 但在設備崩潰。在didselectedRowAtIndexPath設備中的應用程序崩潰

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {  
    NSLog(@"%d",indexPath.row); 
    int k,i=0 ; 
    for (k = 1; k<=indexPath.row; k=k++) {  
     i = k * [appDeleg.tableData count];   
    } 

    NSMutableArray *tempArray = [[NSMutableArray alloc] init]; 
    appDeleg.finalDeptPayment = tempArray; 
    [tempArray release]; 

    for (int j=0; j<[appDeleg.tableData count]; j++) { 

     finalCalculationValue *objFinalValue = [[finalCalculationValue alloc] init]; 

     NSDecimalNumber *dec = [[NSDecimalNumber alloc] initWithDouble:[[appDeleg.ArrRowPayments2 objectAtIndex:i+j] doubleValue]]; 
     objFinalValue.DeptPayment = dec; 

     NSLog(@"%@",dec); 
     [appDeleg.finalDeptPayment addObject:objFinalValue]; 
    }  

    if (objDeptDetail == nil) { 

     objDeptDetail = [[DeptAndPaymentdetail alloc] initWithNibName:@"DeptAndPaymentdetail" bundle:nil]; 

     [self.navigationController pushViewController:objDeptDetail animated:YES]; 

     [objDeptDetail release]; 
     objDeptDetail = nil; 
    }  
} 

示例代碼的話,請告訴我,我做什麼?

+2

在哪一行不調試說它會崩潰? – DarkDust 2011-02-15 12:50:07

回答

2

轉到目標選項卡,查看可執行文件組中的應用程序,然後雙擊它。出現的窗口將標題爲「可執行的」應用程序名稱「信息」,並且將在其中具有兩個表格,最上面的一個標記爲「在啓動時傳遞的參數:」底部的標記爲「要在環境:「

單擊底部表的添加按鈕,爲新變量指定名稱」NSZombieEnabled「和值」YES「。然後關閉窗口並運行你的應用程序(在模擬器或設備上)。

我的猜測是,現在應用程序將在兩種環境中都會異常退出,並通知您刪除後哪個對象正在被使用。

欲瞭解更多信息:http://cocoa-nut.de/?p=16

相關問題