iphone- tableview数字插入

时间:2012-03-13 09:11:22

标签: iphone objective-c

{
  .....
 result *temp = [suff objectAtIndex:indexPath.row];
 NSLog(@"%@", temp.pid);
 cell.pidlab.text = temp.pid;
 ......
}

有一个问题是pid在控制台窗口中打印为数字但是在表格单元格中没有分配我有错误信息..

如何解决?

[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x688dae0
2012-03-13 14:14:31.161 secondDemo1[1978:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x688dae0'
*** First throw call stack:
(0x13be052 0x154fd0a 0x13bfced 0x1324f00 0x1324ce2 0x15368f 0x34c0 0xaee0f 0xaf589 0x9adfd 0xa9851 0x54301 0x13bfe72 0x1d6892d 0x1d72827 0x1cf8fa7 0x1cfaea6 0x1d8630c 0x26530 0x13929ce 0x1329670 0x12f54f6 0x12f4db4 0x12f4ccb 0x12a7879 0x12a793e 0x15a9b 0x21c8 0x2125)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c
(gdb) 

3 个答案:

答案 0 :(得分:2)

最有可能的问题是你试图将label的text属性设置为非NSString(来自错误描述的NSNumber)。

因此,在将值设置为标签之前,需要将值转换为字符串:

cell.pidlab.text = [temp.pid stringValue];

答案 1 :(得分:0)

您正尝试将NSNumber(__ NSCFNumber是NSNumer)分配给NSString。 试试这个

cell.pidlab.text = [temp.pid stringValue];

答案 2 :(得分:0)

pid不是NSString类型的变量。 你需要使用:

cell.pidlab.text = [NSString stringWithFormat@"%d",[temp.pid intValue]];