In objective-c, if I wanted to reverse the value of a BOOL, would this work, or would it set the value of the BOOL to NO?
BOOL ab = YES;
ab = !ab; // would this reverse the BOOL, ab, and set it to NO?
if (ab == NO) {
ab = !ab; // would this reverse the BOOL again and set it to YES?
}
Yes, that will work.
BOOLis just an integer.YESis1andNOis0.!1 == 0and!0 == 1.