Mantle / MTLManagedObjectAdapter

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

make adapter ignore property keys that aren't in the mapping dictionary #27

Closed ilyawiz closed 7 years ago

ilyawiz commented 7 years ago

currently if you add a property to the Mantle subclass via e.g a swift extension then the adapter will fail to deserialize it (CD > mantle) Changing the adapter to ignore unlisted keys, fixes this. The question is, is this behavior (default key mapping) commonly depended upon by developers, and would you accept a pull request with a change to this behavior (maybe with an on/off switch)

the change to MTLManagedObjectAdapter.m

- (NSString *)managedObjectKeyForKey:(NSString *)key {
    NSParameterAssert(key != nil);

    id managedObjectKey = self.managedObjectKeysByPropertyKey[key];
    if ([managedObjectKey isEqual:NSNull.null]) return nil;

    return managedObjectKey;
}
ilyawiz commented 7 years ago

wrong repository, this is relevant to mantle 1.5.x not mantle 2.0