!=在大多數語言意味着不等於 但是怎麼樣=!在目標C?我在下面的代碼片段中找到了它。
由於=的含義是什麼?在目標c
- (void) toggleButton: (UIButton *) aButton
{
if ((_isOn = !_isOn))
{
[self setBackgroundImage:BASEGREEN forState:UIControlStateNormal];
[self setBackgroundImage:PUSHGREEN forState:UIControlStateHighlighted];
[self setTitle:@"On" forState:UIControlStateNormal];
[self setTitle:@"On" forState:UIControlStateHighlighted];
}
else
{
[self setBackgroundImage:BASERED forState:UIControlStateNormal];
[self setBackgroundImage:PUSHRED forState:UIControlStateHighlighted];
[self setTitle:@"Off" forState:UIControlStateNormal];
[self setTitle:@"Off" forState:UIControlStateHighlighted];
}
[self relaxButton:self];
}
這將是爲'_isOn = ISON減少混亂,當一個有價值的rescource!; if(_isOn){...} else {...} ... – nielsbot
它首先將_isOn設置爲自身的「not」,然後返回要在if語句中進行測試的結果值。 –