我試圖編寫代碼來檢測整數是否大於另一個整數。這可能嗎?如何檢查NSInteger是否比另一個NSinteger大?
這是我迄今爲止所做的。
if (NumCorrect >> NumWrong) {
btnCool.title = @"Awww";
}
else {
btnCool.title = @"Cool!";
}
其所有做的是要去別的
編輯:
NSString *numCorrect = [NSString stringWithFormat:@"%d",NumCorrect];
NSString *numWrong = [NSString stringWithFormat:@"%d", NumWrong];
lblWrong.text = numWrong;
lblCorrect.text = numCorrect;
if (NumCorrect > NumWrong) {
btnCool.title = @"Awww";
} else {
btnCool.title = @"Cool!";
}
「>>」是右移。 –
也許你應該NSLog你的號碼,以確保他們是你認爲他們是。 (並且注意不要試圖用'>'比較字符串的錯誤。) –