Objective-C: returning an int BOOL method

I'm new to Objective-C and I wonder why this method compiles, can someone explain to me why?

thank

-(BOOL) isEnabled{
   return 56;
}
+5
source share
2 answers

A BOOLin Objective-C is typedefof signed char. Since it 56is suitable for this type, an implicit conversion from a literal intresults in no data loss.

+6
source

You can think of BOOL in objective-c as

false === 0 === nil   //Anything that is zero or nil is false
true = !false         //Anything that is NOT zero or nil is true. 

56 therefore returns true because it is not zero

0
source

All Articles