> On Feb 18, 2015, at 5:22 PM, Jens Alfke <[email protected]> wrote:
> 
> I’m iterating a protocol’s property list (using protocol_copyPropertyList.) 
> For each property, I want to know whether it was declared as @optional; but I 
> can’t figure out how to do this.
> 
> The closest I’ve come is to call protocol_getProperty, passing in the 
> protocol, the property’s name, and YES for both isRequiredProperty and 
> isInstanceProperty:
>       BOOL isOptional = (protocol_getProperty(protocol, name, YES, YES) == 
> NULL);
> Unfortunately this doesn’t work; the function never returns NULL, even for an 
> optional property. Changing the value of isRequiredProperty to NO doesn’t 
> help; then the function _always_ returns NULL.
> 
> There aren’t any other functions defined in <objc/runtime.h> that look at all 
> relevant, and the property’s attribute string doesn’t include any extra 
> parameter indicating it’s optional, so I’m stumped. Anyone know?

There's no such thing as an optional property nor a class property in a 
protocol. All properties in a protocol are required instance properties. The 
runtime function was written with the expectation that the others would exist, 
but we never implemented them.


-- 
Greg Parker     [email protected]     Runtime Wrangler



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to