Updated to support setting default value instead of nil when an attribute is missing in the payload. For Core Data backed models, we consult the entity definition to obtain the default value. closes #117

This commit is contained in:
Blake Watters
2011-06-28 15:22:04 -04:00
parent 851df3bcba
commit 3dfbaf1810
11 changed files with 47 additions and 18 deletions

View File

@@ -72,4 +72,10 @@
- (id)initWithEntity:(NSEntityDescription*)entity;
/**
Returns the default value for the specified attribute as expressed in the Core Data entity definition. This value will
be assigned if the object mapping is applied and a value for a missing attribute is not present in the payload.
*/
- (id)defaultValueForMissingAttribute:(NSString*)attributeName;
@end

View File

@@ -73,4 +73,9 @@
va_end(args);
}
- (id)defaultValueForMissingAttribute:(NSString*)attributeName {
NSAttributeDescription *desc = [[self.entity attributesByName] valueForKey:attributeName];
return [desc defaultValue];
}
@end