2011-09-21 118 views
2

我不...已瞭解我成功地填充我的表視圖,但是當我把它的滾動崩潰而無消息..當我滾動我的tableview崩潰

創建我tabQuestionNSMutablearray,然後在添加此我代表:cellForRowAtIndexPath

NSDictionary *question = [self.tabQuestion objectAtIndex:indexPath.row]; 

[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator]; 

cell.textLabel.text = [NSString stringWithFormat:@"%@", [question objectForKey:@"question"]]; 
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [question objectForKey:@"reponse"]]; 

if ([[question objectForKey:@"bOk"] isEqualToString:@"1"]) { 
     cell.imageView.image = [UIImage imageNamed:@"ok.png"]; 
} 
else 
{ 
     cell.imageView.image = [UIImage imageNamed:@"ok.png"]; 
} 

[question release]; 



return cell; 

回答

2

你不應該release對象通過的NSArray方法objectAtIndex:返回。這種情況非常罕見。

嘗試刪除首先行:[question release];

然後檢查你的self.tabQuestion包含的對象要緊的量。

+0

如果我只添加這些行我有崩潰 - > NSLog(@「%@%i」,[tabQuestion description],indexPath.row); NSLog(@「%@」,[[self.tabQuestion objectAtIndex:indexPath.row] description]);索引(15)超出範圍(0) –

+0

錯誤表示您的數組包含0個對象。 – Nekto

+0

我找到解決方案。實際上,系統會自動釋放我的對象。我解決它與保留。 –