2011-12-01 71 views
0

如何在if語句中檢查UILabel的值是否大於0?如何在if語句中檢查UILabel的值是否大於0?

我曾嘗試下面的代碼:

if(ArtCount.text.intValue > 0) 
{ 
} 

但它與下面的錯誤回來:

2011-12-01 20:52:50.124 iDHSB[2955:707] -[UILabel isEqualToString:]: unrecognized selector sent to instance 0x1a9860 
2011-12-01 20:52:50.126 iDHSB[2955:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-  
[UILabel isEqualToString:]: unrecognized selector sent to instance 0x1a9860' 
*** First throw call stack: 
(0x323e28bf 0x35cfa1e5 0x323e5acb 0x323e4945 0x3233f680 0x3152b191 0x6cff3 0x316cf871 0x323e5814 0x323407e1 0x323403ff  
0x34767e5b 0x323e4ab3 0x3233f680 0x323e5814 0x323407e1 0x33dcb43d 0x33dde8dd 0x323b6b03 0x323b62cf 0x323b5075 0x323384d5 
0x3233839d 0x378b7439 0x315558e1 0x2d0f 0x2758) 
terminate called throwing an exception[Switching to process 7171 thread 0x1c03] 
(gdb) 
+7

以上代碼不太可能導致上述錯誤。在調試器中,它實際上在哪裏崩潰?你在'UILabel'上調用'isEqualToString:'在哪裏? –

回答

5

錯誤消息:

[UILabel isEqualToString:]: unrecognized selector sent to instance 0x1a9860 
2011-12-01 20:52:50.126 iDHSB[2955:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-  
[UILabel isEqualToString:]: unrecognized selector sent to instance 

表示引起異常線路被調用方法isEqualToString上的UILabel的實例,所提供的代碼不包含此方法調用。

查找在UILabel實例上調用isEqualToString的語句。

0
if ([ArtCount.text intValue] > 0) { 
    ... 
} 

我希望它能幫助!

+6

這與OP的代碼完全相同。當編譯器感到困惑時,偶爾避免像這樣的點符號是必需的,但它不會導致這種特定的運行時錯誤。 –

相關問題