I have a custom tableview cell. But when I want to call this cell in my cellForRowAtIndexpath, it gives the following error.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell lblPosition]: unrecognized selector sent to instance 0xa62a600'
I checked a 100 times if everthing is hooked up correctly and named correctly but still doesn't find what is wrong. This is what I am doing in code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"KlassementCell";
KlassementCell *cell = (KlassementCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"KlassementCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
// ask NSFetchedResultsController for the NSMO at the row in question
Klassement *klassement = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Then configure the cell using it ...
NSString *pointDiff = [NSString stringWithFormat:@"%@", klassement.goalsDiff];
NSLog(@"position %@",klassement.position);
NSLog(@"name %@",klassement.name);
cell.lblPosition.text = klassement.position;
cell.lblName.text = klassement.name;
cell.lblgamesPlayed.text = klassement.gamesPlayed;
cell.lblGamesWon.text = klassement.gamesWon;
cell.lblGamesTied.text = klassement.gamesTied;
cell.lblGamesLost.text = klassement.gamesLost;
cell.lblGoalsPos.text = klassement.goalsPos;
cell.lblGoalsNeg.text = klassement.goalsNeg;
cell.lblGoalsDiff.text = pointDiff;
cell.lblPoints.text = klassement.points;
return cell;
}
Can anybody help?
Kind regards.
Try
if ((cell == nil) || (![cell isKindOfClass: KlassementCell.class])) {
The cell returned in the queue might not be KlassementCell.