Re: BOOL attribute types.
Re: BOOL attribute types.
- Subject: Re: BOOL attribute types.
- From: Greg Parker <email@hidden>
- Date: Mon, 16 Feb 2015 13:25:32 -0800
> On Feb 16, 2015, at 1:06 PM, Alex Zavatone <email@hidden> wrote:
>
> Xcode 5.1.1
> IOS 7.x
>
> I'm messing with an auto description category for NSObjects with the interest of dumping out a class's properties in the format of property name, property class and string equivalent of property value.
>
> I'm also considering supporting scalar primitive types that are not NSObjects, such as CGRects, BOOLs and so on.
>
> In doing this, I'm checking the property's attributes with property_getAttributes().
>
> What is confusing here is that for properties that are declared as a non atomic BOOL, the attributes are Tc,N,V, where c codes for a char, according to the docs, according to the Runtime Property Attribute Description Examples.
>
> A char declared as a property returns exactly the same attributes as a BOOL with property_getAttributes().
>
> But for an NSString, property_getAttributes()returns "T@"NSString",&,N
>
> It's easy to detect the NSString properties, but why isn't BOOL included in a BOOL's property attributes? Is a BOOL just a char (that's what this is telling me)? What is going on under the hood here. How can I properly identify a BOOL and tell the difference between a BOOL and a char if they are represented the same way?
You can't.
64-bit iOS:
typedef bool BOOL;
Everything else:
typedef signed char BOOL;
If you have sufficient control over the property names, you might be able to assume that a property typed "c" named "foo" with a getter named "isFoo" is a BOOL property.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden