2012-03-13 63 views
0
{ 
    ..... 
result *temp = [suff objectAtIndex:indexPath.row]; 
NSLog(@"%@", temp.pid); 
cell.pidlab.text = temp.pid; 
...... 
} 

iphone-的tableview號插入

如何解決它的問題,即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) 
+1

僅供參考,多個問題/感嘆號**不**幫助來獲得更快的回答@ – Vladimir 2012-03-13 09:13:58

+0

賽info.iphone你應該給予好評有益的問題,並標記最有用的接受回答。 – 2012-03-13 09:43:53

+0

據我的觀點,你正在分配數字標籤...所以你必須分配pid與stringWithFormat .....我很可能..ok。:) – Krunal 2012-03-13 14:32:54

回答

0

pid不是NSString類型的變量。 您需要使用:

cell.pidlab.text = [NSString [email protected]"%d",[temp.pid intValue]]; 
0

您試圖分配NSNumber(__NSCFNumber是NSNumer)到NSString。 試試這個

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

%d格式期望純int,而不是NSNumber **對象** – Vladimir 2012-03-13 09:17:36

+0

你工作但有滾動後的所有數字指定一樣?爲什麼? – 2012-03-13 09:20:16

+0

感謝它的完成.. – 2012-03-13 09:25:04

2

最可能的問題是你想標籤的文本屬性設置爲東西是不是一個的NSString(NSNumber的從錯誤的描述)。

所以你需要轉換你的價值爲字符串之前設置標籤:

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

+1 pid可以是int,double等 – 2012-03-13 09:30:22