Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Property Introspection

When the compiler encounters property declarations, it generates descriptive metadata that is associated with the enclosing class, category or protocol. This metadata is accessible through functions that support looking up a property by name on a class or protocol, obtaining the type of a property as an @encode string, and copying a list of a property's attributes as an array of C strings. A list of declared properties is available for each class and protocol.

The Property structure defines an opaque handle to a property descriptor.

typedef struct objc_property *Property;

The functions class_getProperty and protocol_getProperty look up a named property in a class and protocol respectively.

Property class_getProperty(Class cls, const char *name);
Property protocol_getProperty(Protocol *proto, const char *name);

The class_copyPropertyList and protocol_copyPropertyList functions return a malloc'd array of pointers to all of the properties declared in a class (including loaded categories) and protocol respectively.

Property* class_copyPropertyList(Class cls, uint32_t *count);
Property* protocol_copyPropertyList(Protocol *protocol, uint32_t *count);

The property_getInfo function returns the name and @encode type string of a property.

void property_getInfo(Property *property, const char **name, const char **type);

The property_copyAttributeList function returns a malloc'd array of pointers to C strings which represent a property's compile-time attribute list.

const char **property_copyAttributeList(Property *property, unint32_t *count);


< Previous PageNext Page > Hide TOC


Last updated: 2008-02-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice