我想驗證我的uitextfield,它只允許數字不是0(零)。此檢查每次都失敗?當調試結果字符串='0'(我輸入零),因爲我試圖使它失敗,但它不會失敗。似乎無法正確讀取UITextField值
NSString *resultingString = budgetField.text;
if(resultingString == @"0" || [resultingString length] == 0){
[AppHelpers showAlert:@"Dude!" withMessage:@"Don't be cheap I know you have more than a $1"]; //never gets in here.
return;
}
+1 「==」 做一個指針比較。兩個「相等」的字符串不必指向同一個對象。 – 2011-02-28 16:08:16