I have Parent/child class like this:
@interface Parent : MTLModel <MTLJSONSerializing>
- (void)someMethod;
@property a,b,c...; // from the JSON
@property NSArray *childs; // from the JSON
@end
@interface Child : MTLModel <MTLJSONSerializing>
@property d,e,f,...; // from the JSON
@property Parent *parent; // *not* in the JSON
@end
All the fields a to f are in the JSON, with the same name (hence my JSONKeyPathsByPropertyKey method return nil), and the proper JSONTransformer is correctly setup so that the childs array in parent is containing Child class and not NSDictionary.
Everything work forwardly.
But I want, as a convenience, a property in my Child model that reference back to the parent that own it. So that in the code I can do that:
[childInstance.parent someMethod]
How do I do that with Mantle ??
I want, when the parent is parsing the child's JSON and creating the Child class, to add a ref to itself. (With an init method ??)
Thanks.