How to change attribute values ​​when matching with REST using Restkit?

I have a main data object and a REST web interface that use different values ​​for the same attribute. The managed object has an attribute named "type", which is an integer (enum), the REST interface has a string value with the name "type" (strings such as "truck", "car", "moped").

I convert the value from a string to an integer when I get the object using the RKObjectLoaderDelegate method objectLoader:willMapData:. Hope I have to do it.

My question is: when you send / send an object, how and where can I convert a value from integer (enum) back to string values? Is there a point in the serialization process where I can manipulate the values ​​for the put / post action? Should I intercept the subclass with a serializer or RKManagedObjectMapping, or is my delegate called at some point so that I can change the attribute values?

+5
source share
1 answer

, (NSManagedObject), , , Restkit. typeString , () "typeString" json, "type". :

[mapping mapKeyPath:@"type" toAttribute:@"typeString"]

:

[serializationMapping mapKeyPath:@"typeString" toAttribute:@"type"]

, objectLoader:willMapData:, ().

+9

All Articles