user2799156 user2799156 - 1 month ago 4
iOS Question

*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]

I am using tableview apple's lazy loading code in my project,but having exception in project. And error is -

*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]
,here is my code please help.But it is working in other project.I have no delegate method.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"LazyTableCell";
static NSString *PlaceholderCellIdentifier = @"PlaceholderCell";

NSUInteger nodeCount = [self.entries count];

if (nodeCount == 0 && indexPath.row == 0)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
cell.detailTextLabel.text = @"Loading…";

return cell;
}

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (nodeCount > 0)
{
AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];

cell.textLabel.text = appRecord.name;


if (!appRecord.appIcon)
{
if (self.mytable_view.dragging == NO && self.mytable_view.decelerating == NO)
{
[self startIconDownload:appRecord forIndexPath:indexPath];
}

cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];
}
else
{
cell.imageView.image = appRecord.appIcon;
}

}

return cell;

}

Answer

Because cellForRowAtIndexPath is returning a nil value and then configureCellForDisplay is expecting a UITableViewCell. The storyboard or XIB does not have a cell defined with the cell identifier you specified. Better check the spelling of identifier.

Comments