> On Feb 16, 2015, at 1:27 PM, Akis Kesoglou <akiskesog...@gmail.com> wrote:
> 
> objc.h typedefs BOOL as char/bool, as David says, so I don’t think you can 
> infer that a property is BOOL by introspecting the property — you’ll always 
> see char or bool.

I’ll chime in too — there’s no way to tell the difference. If you need to 
detect boolean properties and treat them differently from ‘char’, you’ll have 
to enforce that your classes only use ‘bool’ properties, not ‘BOOL’.

And a bit of advice if you go this route: If you start using ‘bool’ in your 
code, make sure you enable the “Implicit ‘bool’ Conversions” warning in Xcode. 
Otherwise the default semantics of ‘bool’ in C99 allow for some really nasty 
bugs, like
        bool x;
        …
        x = [NSMutableArray array];     // compiles with no warning! :-o
C99 lets you assign a value of almost any type (except for a struct/union) to a 
bool variable. The warning was added later because this turns out to have bad 
side effects. A few years ago I had a serious and very hard to identify bug in 
my code that stemmed from this sort of mistake. After a few hours I stared at 
the assignment statement, then looked up the declaration of the variable, and 
did a double-take when I realized it was a bool and not an object reference…

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to