Docs for property inspector

This commit is contained in:
Blake Watters
2012-09-13 14:53:51 -04:00
parent b4630a246e
commit e1eff40d3d
2 changed files with 38 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
//
// RKObjectPropertyInspector.h
// RKPropertyInspector.h
// RestKit
//
// Created by Blake Watters on 3/4/10.
@@ -22,26 +22,54 @@
@class NSEntityDescription;
/**
The `RKPropertyInspector` class provides an interface for introspecting the properties and attributes of classes using the reflection capabilities of the Objective-C runtime. Once inspected, the properties and types are cached.
*/
@interface RKPropertyInspector : NSObject {
@protected
NSCache *_propertyNamesToTypesCache;
}
+ (RKPropertyInspector *)sharedInspector;
///-----------------------------------------------
/// @name Retrieving the Shared Inspector Instance
///-----------------------------------------------
/**
* Returns a dictionary of names and types for the properties of a given class
Returns the shared property inspector singleton instance.
@return The shared `RKPropertyInspector` instance.
*/
+ (RKPropertyInspector *)sharedInspector;
///------------------------------------------------------
/// @name Retrieving the Properties and Types for a Class
///------------------------------------------------------
/**
Returns a dictionary of names and types for the properties of a given class.
@param objectClass The class to retrieve the property name and types for.
@return A dictionary containing metadata about the properties of the given class, where the keys in the dictionary are the property names and the values are `Class` objects specifying the type of the property.
*/
- (NSDictionary *)propertyNamesAndTypesForClass:(Class)objectClass;
/**
Returns the Class type of the specified property on the object class
Returns the `Class` object specifying the type of the property with given name on a class.
@param propertyName The name of the property to retrieve the type of.
@param objectClass The class to retrieve the property from.
@return A `Class` object specifying the type of the requested property.
*/
- (Class)typeForProperty:(NSString *)propertyName ofClass:(Class)objectClass;
///------------------------------------------------------
/// @name Retrieving the Properties and Types for a Class
///------------------------------------------------------
/**
Returns the name of a property when provided the name of a property obtained
via the property_getAttributes reflection API
Returns the name of a property when provided the name of a property obtained via the `property_getAttributes` reflection API.
@param attributeString A string object encoding attribute information.
@return The class name for the property type encoded in the given attribute string or `@"NULL"` if the property does not have an object type (the declared property is for a primitive type).
*/
+ (NSString *)propertyTypeFromAttributeString:(NSString *)attributeString;

View File

@@ -26,15 +26,15 @@
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
static RKPropertyInspector *sharedInspector = nil;
@implementation RKPropertyInspector
+ (RKPropertyInspector *)sharedInspector
{
if (sharedInspector == nil) {
static RKPropertyInspector *sharedInspector = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInspector = [RKPropertyInspector new];
}
});
return sharedInspector;
}