Created
April 24, 2014 15:12
-
-
Save tanis2000/11258321 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableDictionary *mappingsDictionary = [[NSMutableDictionary alloc] init]; | |
// Add DailyGoalDetails->MGRDailyGoalDetail mapping | |
[mappingsDictionary setObject:[MGRDailyGoalDetail responseMapping] forKey:@"DailyGoalDetails"]; | |
RKMapperOperation *mapper = [[RKMapperOperation alloc] initWithRepresentation:parsedData mappingsDictionary:mappingsDictionary]; | |
RKManagedObjectMappingOperationDataSource *dataSource = [[RKManagedObjectMappingOperationDataSource alloc] initWithManagedObjectContext:[MGRModel sharedModel].managedObjectStore.persistentStoreManagedObjectContext cache:[MGRModel sharedModel].managedObjectStore.managedObjectCache]; | |
dataSource.parentOperation = mapper; | |
mapper.mappingOperationDataSource = dataSource; | |
NSError *mappingError = nil; | |
BOOL isMapped = [mapper execute:&mappingError]; | |
if (isMapped && !mappingError) { | |
NSLog(@"[postJsonGzippedAsData] jsonMappingResult = %@",[mapper mappingResult]); | |
[[[[MGRModel sharedModel] managedObjectStore] persistentStoreManagedObjectContext] save:&mappingError]; | |
} | |
mappingsDictionary = [[NSMutableDictionary alloc] init]; | |
// Add UserSessions->MGRSession mapping | |
[mappingsDictionary setObject:[MGRSession responseMapping] forKey:@"UserSessions"]; | |
mapper = [[RKMapperOperation alloc] initWithRepresentation:parsedData mappingsDictionary:mappingsDictionary]; | |
dataSource.parentOperation = mapper; | |
mapper.mappingOperationDataSource = dataSource; | |
mappingError = nil; | |
isMapped = [mapper execute:&mappingError]; | |
if (isMapped && !mappingError) { | |
NSLog(@"[postJsonGzippedAsData] jsonMappingResult = %@",[mapper mappingResult]); | |
[[[[MGRModel sharedModel] managedObjectStore] persistentStoreManagedObjectContext] save:&mappingError]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment