Hi stackoverflow community,
i’m using RKObjectManager to make iOS RESTful requests to map responses to local objects.
My problem with Restkit, is to register multiple classes for the same Element in different requests. In this requests i have nested objects with the same element name “List”.
Here is part of the code:
// Get array of RKObjects1 - First request of the queue
RKObjectManager * objectManager = [RKObjectManager sharedManager];
[objectManager registerClass:[RKTObject1 class] forElementNamed:@"List"];
RKObjectLoader * loader = [objectManager objectLoaderWithResourcePath:@"objects1" delegate:self];
[loader setObjectClass:[RKTList class]];
// Get array of RKObjects2 - Second request of the queue
RKObjectManager * objectManager = [RKObjectManager sharedManager];
[objectManager registerClass:[RKObjects2 class] forElementNamed:@"List"];
RKObjectLoader * loader = [objectManager objectLoaderWithResourcePath:@"objects2" delegate:self];
[loader setObjectClass:[RKTList class]];
What i would like to know, if there is any solution to register multiple classes for the same element in different requests?
Well, to solve my problem, i update restkit and with the new Object Mapping 2.0 it’s possible to register multiple classes for the same element keys.
You only need to create different RKObjectMapping objects for each request and make setObjectMapping of each object in RKObjectLoader.
For example: