I use RestKit for the project, and I noticed that in this class there is no longer a method that can be controlled by all the mappings in (elementToPropertyMappings), so I wondered where it is best to place the new code, I am currently doing this in my view controller , but I will use most of the same comparisons in other areas of my code, so there is a more efficient place to put it:
The code that I mean is:
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[User class]]; [userMapping mapKeyPath:@"id" toAttribute:@"identifier"]; [userMapping mapKeyPath:@"forename" toAttribute:@"forename"]; [userMapping mapKeyPath:@"surname" toAttribute:@"surname"]; [userMapping mapKeyPath:@"email" toAttribute:@"email"]; [userMapping mapKeyPath:@"twitter_username" toAttribute:@"twitterUsername"]; [userMapping mapKeyPath:@"created" toAttribute:@"created"]; [userMapping mapKeyPath:@"use_gravatar" toAttribute:@"useGravatar"]; [userMapping mapKeyPath:@"avatar_url" toAttribute:@"avatarURL"]; [userMapping mapKeyPath:@"gender" toAttribute:@"gender"]; [[RKObjectManager sharedManager].mappingProvider setMapping:userMapping forKeyPath:@"user"];
It would be great if it could be in the method of the User class, which I can then call to configure these mappings, etc.
Many thanks
object mapping objective-c restkit
Matthew lanham
source share