mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-01 22:42:51 +08:00
Apply rootKeyPath within the mapper rather than the object loader
This commit is contained in:
@@ -214,10 +214,9 @@
|
||||
|
||||
RKObjectMappingProvider* mappingProvider;
|
||||
RKObjectMapping *configuredObjectMapping = [self configuredObjectMapping];
|
||||
if (configuredObjectMapping) {
|
||||
NSString* rootKeyPath = configuredObjectMapping.rootKeyPath ? configuredObjectMapping.rootKeyPath : @"";
|
||||
RKLogDebug(@"Found directly configured object mapping, creating temporary mapping provider for keyPath %@", rootKeyPath);
|
||||
if (configuredObjectMapping) {
|
||||
mappingProvider = [RKObjectMappingProvider mappingProvider];
|
||||
NSString *rootKeyPath = configuredObjectMapping.rootKeyPath ? configuredObjectMapping.rootKeyPath : @"";
|
||||
[mappingProvider setMapping:configuredObjectMapping forKeyPath:rootKeyPath];
|
||||
} else {
|
||||
RKLogDebug(@"No object mapping provider, using mapping provider from parent object manager to perform KVC mapping");
|
||||
|
||||
@@ -334,7 +334,9 @@
|
||||
} else if ([mappingsForContext conformsToProtocol:@protocol(RKObjectMappingDefinition)]) {
|
||||
id mappableData = self.sourceObject;
|
||||
if ([mappingsForContext respondsToSelector:@selector(rootKeyPath)] && [mappingsForContext rootKeyPath] != nil) {
|
||||
mappableData = [self.sourceObject valueForKeyPath:[mappingsForContext rootKeyPath]];
|
||||
NSString* rootKeyPath = [mappingsForContext rootKeyPath];
|
||||
mappableData = [self.sourceObject valueForKeyPath:rootKeyPath];
|
||||
RKLogDebug(@"Selected object mapping has rootKeyPath. Apply valueForKeyPath to mappable data: %@", rootKeyPath);
|
||||
}
|
||||
|
||||
if (mappableData) {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#import "RKObjectMapper_Private.h"
|
||||
#import "RKObjectMapperError.h"
|
||||
#import "RKDynamicMappingModels.h"
|
||||
#import "RKObjectMappingProvider+Contexts.h"
|
||||
|
||||
// Managed Object Serialization Specific
|
||||
#import "RKHuman.h"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#import "RKManagedObjectStore.h"
|
||||
#import "RKSpecResponseLoader.h"
|
||||
#import "RKManagedObjectMapping.h"
|
||||
#import "RKObjectMappingProvider+Contexts.h"
|
||||
#import "RKObjectMappingProvider.h"
|
||||
#import "RKHuman.h"
|
||||
#import "RKCat.h"
|
||||
|
||||
Reference in New Issue
Block a user