Objective-C 2.0 Property Encoding
December 4th, 2007 by Joe RanieriThe only way to inspect an Objective C 2.0 property is with a call to property_getAttributes(); sadly, the data returned by this function is completely undocumented. Here’s what I figured out:
The data is simply a NULL terminated string. Inside this string are several parts, separated by commas. (I’m assuming the order doesn’t matter, but this could be incorrect.)
Misc:
- R - the property is read-only
- T<type> - the property’s type, where <type> is the result of @encode() of the property’s type.
Assignment modes:
- C - the property is copied on assignment
- & - the property is retained on assignment
References:
- P - the property is a strong reference
- W - the property is a weak reference
Property accessors:
- D - the property is dynamic
- G<getter> - the property’s getter (named <getter>)
- S<setter> - the property’s setter (named <setter>)
- V<ivar> - the property is synthesized, using the ivar <ivar>