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?

—Jens

PS: This is on OS X 10.10.3, in a 64-bit process.
 _______________________________________________
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