mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-05-07 23:06:59 +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:
@@ -12,7 +12,6 @@
|
||||
|
||||
#import "RKManagedObjectSeeder.h"
|
||||
#import "RKManagedObjectStore.h"
|
||||
#import "RKManagedObjectFactory.h"
|
||||
#import "../ObjectMapping/RKParserRegistry.h"
|
||||
#import "RKLog.h"
|
||||
|
||||
@@ -114,13 +113,12 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
|
||||
RKObjectMappingProvider* mappingProvider = nil;
|
||||
if (nilOrObjectMapping) {
|
||||
mappingProvider = [[RKObjectMappingProvider new] autorelease];
|
||||
[mappingProvider setObjectMapping:nilOrObjectMapping forKeyPath:@""];
|
||||
[mappingProvider setMapping:nilOrObjectMapping forKeyPath:@""];
|
||||
} else {
|
||||
mappingProvider = _manager.mappingProvider;
|
||||
}
|
||||
|
||||
RKObjectMapper* mapper = [RKObjectMapper mapperWithObject:parsedData mappingProvider:mappingProvider];
|
||||
mapper.objectFactory = [RKManagedObjectFactory objectFactoryWithObjectStore:_manager.objectStore];
|
||||
RKObjectMappingResult* result = [mapper performMapping];
|
||||
if (result == nil) {
|
||||
RKLogError(@"Database seeding from file '%@' failed due to object mapping errors: %@", fileName, mapper.errors);
|
||||
|
||||
Reference in New Issue
Block a user