Is there a way in mantle to update an existing record in core data instead of always create new ones? This blog post looks promising, but I don't find the method updateWithJSON:
somewhere in Mantle. Right now, I'm doing the following:
MantleObject *mantleObject = [MTLJSONAdapter modelOfClass:[MantleObject class] fromJSONDictionary:dictionary error:NULL];
CoreDataObject *coreDataObject = [CoreDataObject MR_findFirstByAttribute:@"primaryKey" withValue:mantleObject.primaryKey];
// avoid duplicates
if (coreDataObject != nil) {
[coreDataObject MR_deleteEntity];
}
[MTLManagedObjectAdapter managedObjectFromModel:mantleObject insertingIntoContext:[NSManagedObjectContext MR_contextForCurrentThread] error:NULL];
It works as expected, but I don't like the idea of always deleting and creating the 'same' object over and over again. So I would love to have the opportunity of updating existing objects (overwriting is fine; ALL the values of the new object can replace the existing ones).