Created
January 30, 2013 13:29
-
-
Save holgersindbaek/4673313 to your computer and use it in GitHub Desktop.
If I map this with only the issue mapping and leave out the article relationship, then everything is fine. If I include the article relationship, then I get the error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'RKManagedObjectMappingOperationDataSource must be initialized with a managed object context.'
This file contains hidden or 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
//Setting up objectmapping for issue | |
RKObjectMapping *issueMapping = [RKObjectMapping mappingForClass:[Issue class]]; | |
[issueMapping addAttributeMappingsFromDictionary:@{ | |
@"title": @"title", | |
@"description": @"description", | |
@"cover_url": @"cover_url", | |
@"published_at": @"published_at", | |
@"issue_number": @"issue_number" | |
}]; | |
//Setting up objectmapping for article | |
RKObjectMapping *articleMapping = [RKObjectMapping mappingForClass:[Article class]]; | |
[articleMapping addAttributeMappingsFromDictionary:@{ | |
@"title": @"title", | |
@"main_text": @"main_text", | |
@"article_image_url": @"article_image_url" | |
}]; | |
[issueMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"articles" toKeyPath:@"articles" withMapping:articleMapping]]; | |
Issue *issue = [Issue new]; | |
RKMappingOperation *operation = [[RKMappingOperation alloc] initWithSourceObject:[parsedData objectForKey:@"issue"] destinationObject:issue mapping:issueMapping]; | |
RKManagedObjectMappingOperationDataSource *dataSource = [RKManagedObjectMappingOperationDataSource new]; | |
operation.dataSource = dataSource; | |
[operation start]; | |
NSLog(@"Parse error: %@", parseError); | |
NSLog(@"Issue title: %@", issue.title); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Blake
I am having exactly the same issue.
Is there any recommended way to parse a local json string with RestKit?