Jon
Jon

Reputation: 4732

UITableViewCell subclass not working

Any ideas why my cell won't show in the table. Its crashing at this code...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"SetTableViewCell";
    SetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil){        
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SetTableViewCell" owner:nil options:nil];

        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[SetTableViewCell class]])
            {
                cell = (SetTableViewCell *)currentObject;
                break;
            }
        }
    }
    [self configureCell:cell atIndexPath:indexPath];

    return cell;
}

Upvotes: 0

Views: 314

Answers (1)

MobileOverlord
MobileOverlord

Reputation: 4610

The most common thing in this case is forgetting to set the UITableViewCell object in interface builder to be of the class SetTableViewCell

Double check this from the Identity Inspector and make sure the Custom Class is set to SetTableViewCell

enter image description here

Upvotes: 2

Related Questions