Mantle / MTLManagedObjectAdapter

Core Data support for Mantle
https://github.com/Mantle/Mantle
MIT License
140 stars 55 forks source link

What is mergeValueForKey:fromManagedObject: used for? #1

Open onmyway133 opened 10 years ago

onmyway133 commented 10 years ago

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

nickynick commented 10 years ago

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.