Closed JuanPabloBoero closed 7 years ago
Hey Juan,
The code is documented here, It's also used in the demo app https://github.com/aryaxt/OCMapper/blob/master/OCMapper/Source/Mapping%20Provider/In%20Code%20Mapping/InCodeMappingProvider.h
This library is not recommended for Objective C, not Swift. Here is a swift version I wrote; mapping is not automated but works much better with Swift
Hi,
Thanks for the reply, yes, i am using Objective-C, what i was missing was the fact that i should make an instance of it and assign it to the ObjectMapper shared instance, like this:
// Handle different keys, for example "id" is system reserved.
InCodeMappingProvider *inCodeMappingProvider = [InCodeMappingProvider new];
[inCodeMappingProvider mapFromDictionaryKey:@"id" toPropertyKey:@"sectorId" forClass:[FAOSector class]];
[inCodeMappingProvider mapFromDictionaryKey:@"nombre" toPropertyKey:@"sectorName" forClass:[FAOSector class]];
[[ObjectMapper sharedInstance] setMappingProvider:inCodeMappingProvider];
NSArray *sectors = [FAOSector objectFromDictionary:jsonData[@"listado"]];
Great pod by the way, thanks!.
I just started using the pod, but had a hard time trying to figure out how to use the inCodeMappingProvider, looks like the documentation is missing, luckly i have found a blog talking about using OCMapper in swift that had a code example.
http://leaks.wanari.com/2016/05/12/3-json-libraries-and-a-converter/