Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C: Returning int to BOOL method

I am new to Objective-C and i wonder why this method compiles, can anyone explain me why?

Thank you

-(BOOL) isEnabled{
   return 56;
}
like image 997
Zillan Avatar asked Jun 06 '12 12:06

Zillan


1 Answers

A BOOL in Objective-C is a typedef of signed char. Since 56 fits in that type, the implicit conversion from a literal int results in no data loss.

like image 182
Jonathan Grynspan Avatar answered Oct 02 '22 14:10

Jonathan Grynspan