Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 目标C错误[\uu NSCFNumber length]:发送到实例的选择器无法识别_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 目标C错误[\uu NSCFNumber length]:发送到实例的选择器无法识别

Ios 目标C错误[\uu NSCFNumber length]:发送到实例的选择器无法识别,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在编写一个基于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 Signatu

我正在编写一个基于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'
当我有以下代码时,应用程序会工作:

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;
我用以下代码替换代码时出错:

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;
我已经创建了一个带有“.h”和“.m”的类“ProduitCell”,我的.h文件中有3个属性。我已将故事板中的这些属性与Xib中的正确单元格项目链接


感谢您的帮助。

检查下一行,如果它是
NSNumber
类类型,则使用以下命令更改它:-

我用了:

cell.priceLabel.text = [NSString stringWithFormat:@"%@",[prixData objectAtIndex:indexPath.row]];

谢谢。

这个错误本质上表明,您希望成为
NSString
的东西实际上是一个
NSNumber
(从
长度
消息判断)。基于这两个代码段并假设第一个代码段正常工作,我将双重检查
[prixData objectAtIndex:indexPath.row]
…和@Alladinian说的一样,但我还要检查
[urlData objectAtIndex:indexath.row]
@LyndseyScott很好,我错过了那个:谢谢你,Alladinian和Lyndsey Scott。我查过了,那是prixData!如果查看异常堆栈跟踪,您将看到在故障点传递的是NSNumber,而不是NSString。
cell.priceLabel.text = [NSString stringWithFormat:@"%@",[prixData objectAtIndex:indexPath.row]];