2009-08-21 67 views
0

該應用程序將運行良好,然後崩潰 - 字面上每隔一段時間。看起來崩潰清理了內存,乾淨的運行損壞了內存。我的iPhone模擬器崩潰Everywhere時間我運行它

我認爲它與內存分配有關,但我不確定。

alt text

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *MyIdentifier = @"MyStateCell"; 
static NSString *MyNib = @"StateCell"; 

StateCell *cell = (StateCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 

if (cell == nil) { 
    UIViewController *c = [[UIViewController alloc] initWithNibName:MyNib bundle:nil]; 
    cell = (StateCell *)c.view; 

    [c autorelease]; 
} 

// Configure the cell. 
NSString *cellAnswerName = [[NSString alloc] initWithFormat:@""]; 
cellAnswerName = [theQuizArray objectAtIndex:indexPath.row]; 
int theStatusCode = [[theResultArray objectAtIndex:indexPath.row] intValue]; 

NSString *statusString; 
NSString *pointsWon; 

if(theStatusCode == 0){ 
    statusString = [NSString stringWithFormat:@""]; 
    pointsWon = [NSString stringWithFormat:@""]; 
}else if(theStatusCode == 12){ 
    statusString = [NSString stringWithFormat:@"Wrong"]; 
    pointsWon = [NSString stringWithFormat:@"0"]; 
}else if(theStatusCode == 11){ 
    statusString = [NSString stringWithFormat:@"Out of time"]; 
    pointsWon = [NSString stringWithFormat:@"0"]; 
}else{ 
    int elapsedTime = 10 - theStatusCode; 
    int pointsWonInt = 10 * theStatusCode; 
    pointsWon = [NSString stringWithFormat:@"%i", pointsWonInt]; 
    if(elapsedTime == 1){ 
     statusString = [NSString stringWithFormat:@"%i second", elapsedTime]; 
    }else{ 
     statusString = [NSString stringWithFormat:@"%i seconds", elapsedTime]; 
    } 
} 

NSString *imagePath = [[@"State_" stringByAppendingString:cellAnswerName] stringByAppendingString:@".png"]; 
UIImage *image = [UIImage imageNamed:imagePath]; 

[[cell stateImage] setImage:image]; 
[[cell stateName] setText:cellAnswerName]; 
[[cell stateResult] setText:statusString]; 
[[cell statePoints] setText:pointsWon]; 


if([statusString isEqualToString:@"Wrong"]) 
[[cell stateResult] setTextColor:[UIColor redColor]]; 


return cell; 

}

回答

0

這是非常奇怪的。

當你說「每隔一段時間」,你如何運行應用程序?構建並運行?或者只是運行?

如果是構建並運行,您是否有任何自定義構建階段來複制文件或執行任何自定義處理?

回溯指示在NIB加載過程中發生崩潰,尤其是在設置插座時。有沒有機會將錯誤的對象作爲文件的所有者?也許有不同的代碼路徑,取決於應用程序啓動時從文件系統讀取的內容?

+0

建立和運行總是 – Bryan 2009-08-21 23:24:37

+0

我沒有做任何自定義處理。我只是用一些數據加載一個文本文件。沒有什麼瘋狂的事情。感謝您的回答bbd – Bryan 2009-08-21 23:26:56

+0

發佈您的cellForRowAtIndexPath方法 – Jordan 2009-08-22 07:45:15

相關問題