Closed arthabus closed 8 years ago
Hi, glad you find the library helpful.
[inCodeMappingProvider mapFromDictionaryKey:@"associateTag" toPropertyKey:@"tags" withObjectType:Tag.class forClass:OuterModel.class];
this should do it.
Thanks for your response, seems like this is what I've been looking for!
🍻
Hi!
First of all, thanks for the library!
I have a question though. How can I map a nested array with a custom mapped filed? I'll explain with example below.
Having the following json object:
{ "name": "Name", "associateTags": [ { "id": 1, "tagName": "Tag Name" } ] }
And the models:
@interface Tag
@property (nonatomic, strong) NSString id; @property (nonatomic, strong) NSArray tagName; @end
@interface OuterModel
@property (nonatomic, strong) NSString name; @property (nonatomic, strong) NSArray tags; @end
And OuterModel.tags property is mapped as the following:
@"tags":@"associateTags"
The problem is that instead of instantiating NSArray of Tag classes (using the mapped values) it seems like OCMapper tries to instantiate AssociateTag classes.
I've currently ended with renaming Tag model to AssociateTag however it means I'm bound to server side model naming. Having an ability to name classes according to custom mapping would be great. Is this something that is supported or I'm missing something? If it's not supported right now, can you please point the right direction to update the code of the library (class/method name)?
Thanks!