Let's say I have a pointer to some object, called myObject
, and I need to know, whether it is really pointing to something. How can this code:
// assume MyObjectClass *myObject;
return (BOOL)myObject;
return 112? I know, that I can always write
return (myObject == nil);
and everything will be fine. But until today I have always assumed, that explicit casting of anything to bool will always return true
or false
(as far as I know, 0 is always considered as false
and any other value as true
) and that BOOL with it's YES
and NO
values is just "renamed" bool. So basically, my questions are:
- Why is it returning 112? :-)
- Are results of explicit casting defined somewhere in C/Objective-C standard, or is it compiler-specific?