Adds a convenience to NSEntityDescription to allow specification of identifier key

parent 04e3630c
......@@ -61,4 +61,9 @@
*/
- (void)buy_updateObject:(id<BUYObject>)object withJSON:(NSDictionary *)JSON;
/**
* Convenience to access JSONPropertyKey for the "identifier" attribute
*/
@property (strong, nonatomic, readonly) NSString *JSONIdentifierKey;
@end
......@@ -177,4 +177,11 @@
[object setValuesForKeysWithDictionary:results];
}
- (NSString *)JSONIdentifierKey
{
NSAttributeDescription *attributeDescription = self.attributesByName[@"identifier"];
return attributeDescription.JSONPropertyKey ?: @"id";
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment