【发布时间】:2010-08-06 06:49:39
【问题描述】:
我创建了自己的笔尖,并为它上课。我将所有控件连接到界面生成器中的类。当我运行它时,它运行良好。唯一的问题是,当我滚动 tableview 时它崩溃了。任何想法可能是什么错误?我一直试图解决这个问题一段时间无济于事。它给出了一个 EXC_BAD_ACCESS,我不确定如何调试。
int cellType = [streamDataProvider cellTypeForIndex:indexPath.row];
if(cellType == HOP_GRAFITTI){
static NSString *CellIdentifier = @"HopGrafittiStreamCell";
HopGrafittiStreamCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HopGrafittiStreamCell" owner:self options:nil];
cell = (HopGrafittiStreamCell *)[nib objectAtIndex:0];
[cell retain];
}
[cell.username setText: [streamDataProvider userNameForIndex:indexPath.row]];
[cell.venuename setText: [streamDataProvider venueNameForIndex:indexPath.row]];
[cell.grafittiText setText: [streamDataProvider grafittiForIndex:indexPath.row]];
return cell;
}
【问题讨论】:
-
没关系——事实证明 streamDataProvider 有一个内部对象没有被保留并被垃圾回收
-
您可以使用 Instruments 中的 Zombies 工具来调试这样的崩溃。
标签: iphone cocoa-touch uikit nib