我有2個按鈕,每個都有標籤。我怎麼能比較他們之間,每個與他自己的標籤和圖像。例如:比較兩個標記的對象?
// sender is (UIButton *)sender.
if ((sender.tag == 1)theImageOnTheButton == (sender.tag == 2)theImageOnTheButton
{
// egual
}
else
// not egual
所以,如果不是標記爲1發件人,他的形象是等於與標籤2發送者,他的形象是平等的,等於說,否則,說他們不是egual。我怎樣才能做到這一點?
原來的代碼是:
-(void)flipView:(UIButton*)sender
{
x = x + 1;
if (x == 1)
{
// When flipping the first card
NSLog(@"X == 1");
[sender setTag:1];
}
else if (x == 2)
{
// When flipping the second card
NSLog(@"X == 2");
x = 0;
[sender setTag:2];
if ((sender.tag == 2) == (sender.tag == 1))
{
NSLog(@"IGUAL");
}
else
{
NSLog(@"NOT EGUAL");
}
}
}
感謝配發。
我認爲你需要重新說明你的問題,因爲它目前沒有任何意義。您發佈的代碼是可讀/有效的語法。 – Dima