As I don't want to hijack another thread here comes my question about mappings.
First read: Where's the best place to put object mappings in RestKit
I'm sure that the answer Blake Waters gave will probable be very correct as he is a much smarter and more experienced guy than I am, but to me logic tells me to put the mapping in each model: if you change something in your model, you're just a scroll away to change your mappings.
In my AppDelegate I would then just call the initMappings (or whatever you want to call it) in each of my models.
I'm also a fan of placing the mappings with my models. I do it by adding a class method to each model so I can get the mapping whenever/wherever I need it.
+ (RKObjectMapping *)objectMapping
{
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[self class]];
[mapping mapKeyPath:@"Id" toAttribute:@"id"];
[mapping mapKeyPath:@"Subject" toAttribute:@"subject"];
[mapping mapKeyPath:@"Message" toAttribute:@"message"];
[mapping mapKeyPath:@"PostDate" toAttribute:@"postDateStr"];
[mapping mapKeyPath:@"StatusId" toAttribute:@"statusId"];
[mapping mapKeyPath:@"StatusDate" toAttribute:@"statusDateStr"];
mapping.setNilForMissingRelationships = YES;
return mapping;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With