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

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

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

7条回答
  •  自闭症患者
    2020-12-11 10:30

    If it always adds, then your string is never "+".

    The logic as you have it will always add a+b unless the txtOperator.txt is exactly equal to @"+".

    Interestingly if you did pass a plus it would always subtract, only the first two cases would ever be hit because if the first was not true the second always would be.

    Basically, take out all the "!"....

提交回复
热议问题