mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-02 22:42:45 +08:00
Added support for configuring objectClass using the class name instead of Class object.
This commit is contained in:
@@ -59,6 +59,13 @@ relationship. Relationships are processed using an object mapping as well.
|
||||
*/
|
||||
@property (nonatomic, assign) Class objectClass;
|
||||
|
||||
/**
|
||||
The name of the target class the receiver defines a mapping for.
|
||||
|
||||
@see objectClass
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *objectClassName;
|
||||
|
||||
/**
|
||||
The aggregate collection of attribute and relationship mappings within this object mapping
|
||||
*/
|
||||
@@ -146,6 +153,14 @@ relationship. Relationships are processed using an object mapping as well.
|
||||
*/
|
||||
+ (id)mappingForClass:(Class)objectClass;
|
||||
|
||||
/**
|
||||
Creates and returns an object mapping for the class with the given name
|
||||
|
||||
@param objectClassName The name of the class the mapping is for.
|
||||
@return A new object mapping with for the class with given name.
|
||||
*/
|
||||
+ (id)mappingForClassWithName:(NSString *)objectClassName;
|
||||
|
||||
/**
|
||||
Returns an object mapping useful for configuring a serialization mapping. The object
|
||||
class is configured as NSMutableDictionary
|
||||
|
||||
@@ -45,6 +45,10 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
|
||||
return [mapping autorelease];
|
||||
}
|
||||
|
||||
+ (id)mappingForClassWithName:(NSString *)objectClassName {
|
||||
return [self mappingForClass:NSClassFromString(objectClassName)];
|
||||
}
|
||||
|
||||
+ (id)serializationMapping {
|
||||
return [self mappingForClass:[NSMutableDictionary class]];
|
||||
}
|
||||
@@ -120,6 +124,14 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)objectClassName {
|
||||
return NSStringFromClass(self.objectClass);
|
||||
}
|
||||
|
||||
- (void)setObjectClassName:(NSString *)objectClassName {
|
||||
self.objectClass = NSClassFromString(objectClassName);
|
||||
}
|
||||
|
||||
- (NSArray *)mappedKeyPaths {
|
||||
return [_mappings valueForKey:@"destinationKeyPath"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user