I need your help with something because I can't think it over. I use Mantle with CoreData on iOS.
I have defined relationships that look like this:
Message 1: N Comment
When I retrieve data from my REST service, I create a message to a Mantle Object that has NSMutableArray comments. It works flawlessly.
Then I save this to Core Data, and it is there that I do not know if I am doing the right thing.
[MTLManagedObjectAdapter managedObjectFromModel:post insertingIntoContext:[self getManagedObjectContext] error:&error];
So, I am doing this to save the post object in Core Data. The master data model has a relationship called "post_has_comments", which is a cascading one-to-many relationship. So, on the Post object, I have "posts_has_comments" โ cascading, on my Comment object I have a one-to-one relationship with "Nullify".
Afaik, Core Data views this as an NSSet. What I'm trying to include is NSMutableArray, although Mantle will take care of it (at least this is what the quick story said in its source).
Unfortunately, when I return an object from Core Data using
Post* post = [MTLManagedObjectAdapter modelOfClass:Post.class fromManagedObject:[[self fetchedResultsController] objectAtIndexPath:indexPath] error:nil];
The comments on the property of the post object are an empty NSSet, and I get quite some errors when pasting things in advance. Errors I get:
Core Data: annotation: repairing missing delete propagation for to-many relationship post_has_comments on object [...]
I'm stuck - Maybe I'm missing something huge here?
My Post Class implements the following static methods:
+ (NSDictionary *)managedObjectKeysByPropertyKey { return @{ @"post_id" : @"id", @"comments" : @"post_has_comments" }; } + (NSDictionary *)JSONKeyPathsByPropertyKey { return @{ @"post_id" : @"id", }; } + (NSDictionary *)relationshipModelClassesByPropertyKey { return @{ @"comments" : IHComment.class }; }