Objective C error [__NSCFNumber length]: unrecognized selector sent to instance

ios, objective-c, uitableview

Solution

Check the below line, if it is `NSNumber` class type then change it below by using stringValue:-

cell.priceLabel.text = [[prixData objectAtIndex:indexPath.row]stringValue];

Problem

i m writing an tableView based application. All works perfectly when i use default cells in my tableView. When i try to make customs cells i have this error : ``` 2014-12-01 22:50:01.690 Signaturegourmande[15701:624637] -[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000c3 2014-12-01 22:50:01.716 Signaturegourmande[15701:624637] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000c3' ``` The Application works when i have this code : ``` static NSString *simpleTableIdentifier = @"SimpleTableItem"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; } cell.textLabel.text = [nomData objectAtIndex:indexPath.row]; return cell; ``` I have the error when i replace the code with this : ``` static NSString *simpleTableIdentifier = @"ProduitCell"; ProduitCell *cell = (ProduitCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProduitCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } cell.nameLabel.text = [nomData objectAtIndex:indexPath.row]; cell.thumbnailImageView.image = [UIImage imageNamed:[urlData objectAtIndex:indexPath.row]]; cell.priceLabel.text = [prixData objectAtIndex:indexPath.row]; return cell; ``` I have created a class "ProduitCell" with the ".h" and ".m", i have 3 property in my .h file. i have linked these property in my storyBoard with the right cells items in my Xib. Thanks for your help.

Original source