Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

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;

}
like image 846
user2799156 Avatar asked Nov 22 '13 07:11

user2799156


2 Answers

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.

like image 81
Praveen Matanam Avatar answered Nov 16 '22 00:11

Praveen Matanam


Please check for Delegate.

Have you added both delegate or not?

UITableViewDelegate, UITableViewDataSource

import UIKit

class UserFriendVC: UIViewController, UITableViewDelegate, UITableViewDataSource 
{

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}
like image 34
Piyushkumar Avatar answered Nov 16 '22 02:11

Piyushkumar