mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
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:
@@ -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
|
||||
|
||||
@@ -73,4 +73,9 @@
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
- (id)defaultValueForMissingAttribute:(NSString*)attributeName {
|
||||
NSAttributeDescription *desc = [[self.entity attributesByName] valueForKey:attributeName];
|
||||
return [desc defaultValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user