Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping multiple resources from one ObjectManager in RestKit

I'm writing a client for a semi-REST web service (for now it only supports GET requests).

My problem is next. I have one base URL and two types of resources each one on the different resource path.

By this time I have two classes that represent that resources structures, I have two instances of RKObjectMapping for mapping each resource type, and I have two instances of RKObjectManager each one with different mapping. In app I load resources calling loadObjectsAtResourcePath: on each instance of RKObjectManager.

Can someone suggest how can I improve my code, because I feel that I should use only one instance of RKObjectManager as I work with only one web service.

I will be very thankful for any advice, because I've searched a lot and haven't found any solution.

like image 886
Uko Avatar asked Oct 24 '11 09:10

Uko


1 Answers

In order to use one RKObjectManager, I think you can do something like this:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:somePath 
                                                usingBlock:^(RKObjectLoader* loader) {
    // Set the mapping to use for this particular request
    loader.objectMapping = specificObjectMappingRequired;
    loader.delegate = ...
}];

See RKObjectManager reference for more info.

like image 95
Mike Mertsock Avatar answered Oct 02 '22 19:10

Mike Mertsock