What does the exclamation mark mean in an Objective-C if statement?

前端 未结 7 1023
無奈伤痛
無奈伤痛 2020-12-11 09:57

I am wondering what the exclamation mark in if(!anObject) means.

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 10:22

    It's a C operator, simply meaning "not". So !YES == NO and !NO == YES are both true statements. if (![txtOperator.text isEqualToString: @"+"]), for example, checks to see if txtOperator.text is NOT equal to @"+".

提交回复
热议问题