Many of Instant Cocoa’s capabilities come from the ability to inspect a class’s properties at runtime. Classes that are inspectable conform to the
ICInspectable protocol, which contains only one method.
It returns a dictionary that has strings for keys and instances of
ICPropertyAttributes as values.
ICPropertyAttributes class stores all the metadata about a property. For example, if a property were annotated:
@property (nonatomic, strong, readonly) NSString *username;
name(NSString) - the name of the property. In the above example, this value would be
readOnly(BOOL) - whether or not the property is readonly
nonatomic(BOOL) - whether or not the property is nonatomic
weak(BOOL) - whether or not the property is weak
dynamic(BOOL) - whether or not the setters and getters are synthesized dynamically with the
memoryManagementPolicy(ICMemoryManagmentPolicy) - the memory management policy for the property. Values include
protocols(NSSet) - a set of
NSStringsof each protocol that that property is specified to conform to. If a property’s type were
id<NSObject, NSCopying>, this value would be a set with the string
@"NSCopying". This does not include protocols that the class conforms to.
instanceVariable(NSString) - the name of the instance variable backing the property. In the above example, this value would be
type(NSString) - the Objective-C type of the property. In the above example, this value would be
@"object". This will probably change to an enumeration in the near future.
className(NSString) - the name of the class. The value of an
idis the empty string. In the above example, this value would be
getter(SEL) - the getter for the property. In the above example, this value would be
setter(SEL) - the setter for the property. Read-only properties return NULL. In the above example, this value would be
This class’s name will change to
ICModelInspector class is initialized with a class:
It returns the
properties dictionary for that class.
It currently does not return computed properties, but this may change.
Properties are currently cached with a static
NSCache. Currently, there isn’t a public way to clear the cache.