开发者

What's the shortest way to negate a BOOL in Objective-C?

开发者 https://www.devze.com 2023-02-18 22:08 出处:网络
I remember in Java you could just go bool yesNo = YES; !yesNo; and it would be NO automatica开发者_高级运维lly.I\'ve tried this a few times in Objective-C but it doesn\'t seem to work.Is there a la

I remember in Java you could just go

bool yesNo = YES;
!yesNo;

and it would be NO automatica开发者_高级运维lly. I've tried this a few times in Objective-C but it doesn't seem to work. Is there a language specific way to do this in Objective-C?


It works more or less the same way - you just have to remember to assign the result of the negation expression back to the variable, like so:

yesNo = !yesNo;
0

精彩评论

暂无评论...
验证码 换一张
取 消