0
votes

Is there a way to use RestKit as an object mapper, say I give it a JSON string and an object mapping, then it gives me the object entity, without setting up the server and all those network related stuff?

Thanks!

updated:

what I need is:

  1. give Restkit an RKObjectMapping, the object class and JSON string
  2. get the parsed object.

what RestKit documentation told me is:

RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://restkit.org"];
[objectManager.mappingProvider setMapping:articleMapping forKeyPath:@"articles"];
RKObjectLoader* loader = [RKObjectManager loadObjectsAtResourcePath:@"/articles" delegate:self];

where I do not need to create the object manager and load objects.

2

2 Answers

0
votes

Did you read the Wiki that has been provided?

RestKit: Object mapping

I personally enjoy using AFNetworking for networking and parsing the JSON and then use MagicalRecord for object mapping and other Core Data work.

0
votes

The solution is to use:

RKObjectMappingOperation *op = [RKObjectMappingOperation mappingOperationFromObject:jsonDict toObject:myObject withMapping:[MyObject mapping]];
[op performMapping:&error];