Odd Behaviour of BOOL in iOS7

I might be going mad here, but previously when using a BOOL I would do something like this :

BOOL myBool

if (myBool) {
  NSLog@"My Bool is YES";
}

I.e I would assume that if myBool is equivalent to saying if myBool is YES.

Under iOS7 though I am seeing the log statement trigger even when the value of myBool is never explictily set. If it is set to NO or YES the code behaves as expected.

Has something changed here under iOS7 ?

EDIT

Just to add that this moment of madness was caused but the fact that I had been elsewhere initialising BOOLs from NSUserDefaults boolForKey method, which will return NO if no value is found for that key.

Answers


If myBool is never explicitely set and it's a local variable, then its value is UNDEFINED. Therefore, it can evaluate to either YES or NO.

Aren't you getting some compiler warnings?


Need Your Help

Draw and fill a signal

c# drawing

I would like to draw and then fill a signal using graphics.drawcurve and graphics.fillclosedcurve as following:

Send Email Attachement using byte[] with Java-Mail

java email

I have a byte array wich i wish to add as an attachement to an email i am sending.