iOS:lldb EXC_BAD_ACCESS自定义单元格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"LibraryListingCell"; InSeasonCell *cell = (InSeasonCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"InSeasonCellView" owner:self options:nil]; cell = [_cell autorelease]; _cell = nil; } if(_dataController!=NULL){ Product *productAtIndex = [_dataController objectInListAtIndex:indexPath.row]; // Configure the cell... if (productAtIndex.name != nil && productAtIndex.week != nil && productAtIndex.image != nil) { cell.name.text = productAtIndex.name; cell.week.text = productAtIndex.week; cell.image.image = productAtIndex.image; } } return cell; } 

消息ERROR为cell.name.text cell.week.text cell.image.text 。 很确定这是一个内存pipe理错误。 尽我所知,我已经保留并正确地发布了。 该应用程序将在启动时崩溃,有时会加载一切正常,但是当您滚动它崩溃。 任何帮助或指针内存pipe理表示赞赏。

而不是这个:

  if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"InSeasonCellView" owner:self options:nil]; cell = [_cell autorelease]; _cell = nil; } 

你发送autorelease消息,并将其设置为零,以后你试图访问释放的cell

我认为这应该是:

 static NSString *CellIdentifier = @"LibraryListingCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; }