Objective C error [__NSCFNumber length]:发送到实例的无法识别的选择器

mad*_*ask 2 objective-c uitableview ios

我正在写一个基于tableView的应用程序.当我在tableView中使用默认单元格时,一切都很完美.当我尝试制作海关单元时,我有这个错误:

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'
Run Code Online (Sandbox Code Playgroud)

当我有这个代码时应用程序工作:

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;
Run Code Online (Sandbox Code Playgroud)

当我用这个替换代码时,我有错误:

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;
Run Code Online (Sandbox Code Playgroud)

我用".h"和".m"创建了一个"ProduitCell"类,我的.h文件中有3个属性.我已将StoryBoard中的这些属性与我的Xib中的右侧单元格项链接起来.

谢谢你的帮助.

Hus*_*bir 7

检查下面的行,如果它是NSNumber类类型,则使用stringValue在下面更改: -

cell.priceLabel.text = [[prixData objectAtIndex:indexPath.row]stringValue];
Run Code Online (Sandbox Code Playgroud)