Ok, so I have an NSDictionary that holds a boolean value. It's loaded from the server and parsed by the framework, and for some reason it ends up being stored as an NSCFBoolean in the dictionary (don't ask, all I know is that the -class method returns __NSCFBoolean).
Since NSCFBoolean is a framework-private class that I cannot use directly, I make a reference to it:
id myBool = myDict[@"my_bool"];
Now comes the cool part: evaluating it. I used a breakpoint and the "po" command. These are the results:
> po myBool
0
> po [myBool class]
__NSCFBoolean
> po [myBool boolValue]
<nil>
What the..?
> po myBool == true
false
> po myBool == false
<nil>
brain melts
How is it possible that == true returns false and == false returns nil?
I have a number of years of experience in programming in Objective-C but I have never seen this weird behaviour before! I've read several articles about the differences between the different boolean types and their behaviours and quirks (This article at NSHipster is quite interesting) but I've read nothing that would explain this behaviour.