MTLManagedObjectAdapter icon indicating copy to clipboard operation
MTLManagedObjectAdapter copied to clipboard

What is mergeValueForKey:fromManagedObject: used for?

Open onmyway133 opened this issue 10 years ago • 1 comments

In MTLManagedObjectAdapater.m

if (managedObject == nil) {
        managedObject = [entityDescriptionClass insertNewObjectForEntityForName:entityName inManagedObjectContext:context];
    } else {
        // Our CoreData store already has data for this model, we need to merge
        [self mergeValuesOfModel:model forKeysFromManagedObject:managedObject];
    }

I see that you give user a chance to merge themselves before those serializeAttribute blocks get called.

I just wonder what mergeValueForKey:fromManagedObject: is used for? It seems to be overridden by serializeAttribute blocks

onmyway133 avatar Aug 10 '14 04:08 onmyway133

This method is supposed to work the other way around - it may be used to update your model with the values from the existing managed object. Frankly, I don't particularly like how it throws a naked managed object at you, but that's how it is for now.

nickynick avatar Aug 11 '14 19:08 nickynick