mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Added support for polymorphic object mapping (Github #105, #244). This enables you to dynamically map objects to different destination classes or using different mapping strategies via configuration or callbacks. See Docs/Object Mapping.md for details.
Other changes include: * Eliminated the RKObjectFactory protocol and implementations. Object mapping instances themselves are now responsible for instantiating target objects for mapping. * Introduced RKObjectAbstractMapping superclass for RKObjectMapping and RKObjectPolymorphicMapping. * Updated example applications to use block object loaders (RKTwitter and RKTwitterCoreData) * Refactored method signatures of RKObjectMapper, RKObjectMapping, and RKObjectMappingProvider to reflect the existence of abstract mapping types. This was necessary to make polymorphic mappings integrate cleanly. * Fixed overlap in RestKit error domains between network and object mapping. fixes #208
This commit is contained in:
@@ -127,16 +127,6 @@
|
||||
|
||||
#pragma mark - Subclass Hooks
|
||||
|
||||
/**
|
||||
Overloaded by RKManagedObjectLoader to provide support for creation
|
||||
and find/update of managed object instances
|
||||
|
||||
@protected
|
||||
*/
|
||||
- (id<RKObjectFactory>)createObjectFactory {
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
Overloaded by RKManagedObjectLoader to serialize/deserialize managed objects
|
||||
at thread boundaries.
|
||||
@@ -179,7 +169,6 @@
|
||||
}
|
||||
|
||||
RKObjectMapper* mapper = [RKObjectMapper mapperWithObject:parsedData mappingProvider:mappingProvider];
|
||||
mapper.objectFactory = [self createObjectFactory];
|
||||
mapper.targetObject = targetObject;
|
||||
mapper.delegate = self;
|
||||
RKObjectMappingResult* result = [mapper performMapping];
|
||||
@@ -208,7 +197,7 @@
|
||||
NSString* rootKeyPath = self.objectMapping.rootKeyPath ? self.objectMapping.rootKeyPath : @"";
|
||||
RKLogDebug(@"Found directly configured object mapping, creating temporary mapping provider %@", (rootKeyPath ? @"for keyPath '%@'" : nil));
|
||||
mappingProvider = [[RKObjectMappingProvider new] autorelease];
|
||||
[mappingProvider setObjectMapping:self.objectMapping forKeyPath:rootKeyPath];
|
||||
[mappingProvider setMapping:self.objectMapping forKeyPath:rootKeyPath];
|
||||
} else {
|
||||
RKLogDebug(@"No object mapping provider, using mapping provider from parent object manager to perform KVC mapping");
|
||||
mappingProvider = self.objectManager.mappingProvider;
|
||||
|
||||
Reference in New Issue
Block a user