Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6777841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:11:45+00:00 2026-05-26T16:11:45+00:00

I am testing out RestKit and need to access different BaseUrls and also sometimes

  • 0

I am testing out RestKit and need to access different BaseUrls and also sometimes access a web service with the same baseUrl from different places “at once”, lastly I also need to access the same baseUrl with different ressourcePaths in the same controller.

In my app delegate I set up the RKObjectManager singleton like this.

RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:kBaseUrl];
[objectManager registerClass:[EntityClass1 class] forElementNamed:@"element1"];
[objectManager registerClass:[EntityClass2 class] forElementNamed:@"element2"];
.
.
.
etc.

The singleton approach is really easy to work with, I however can’t figure out how to separate the different web service calls.

In MyViewController, which implement the RKObjectLoaderDelegate, I will have the two methods:

- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects         {
    //stuff with result
}

- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error {
    //stuff with error    
}

This causes no problems when MyViewController uses one RKObjectManager singleton to access one ressourcePath with one baseUrl.

If I start different requests in this way:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:FLICKRPath delegate:self]
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:FOURSQUAREPath delegate:self]

and so on, within the same MyController, my problem is that FLICKRPath and FOURSQUAREPath of course has different baseUrl, but the RKObjectManager only has one?

If I get this working and can have different RKObjectManagers another problem arises.
The delegate methods didLoadObjects and didFailWithError will receive results from both RKObjectManagers and I can’t see any other way to tell them apart than from their baseUrls. Potentially comparing each return value with a baseUrl and, even worse, a ressourcePath, in the delegate method does not appeal to me at all.

If I have different RKObjectManagers I guess I could pass them different delegates and build classes dedicated to deal with the return values from different baseUrls and ressourcePaths. This would mean I had to build yet another abstraction on top of MyController and RestKit, which also seems messy.

I have a strong feeling I am going about this in the wrong way, the RestKit source is very impressive which indicates that is me fighting the framework. I would really appreciate some best practice insights on the subject. I have been through all the resources and examples that I could find but have not seen the above use case. It is always one RKObjectManager, one baseUrl and one ressourcePath.

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:11:45+00:00Added an answer on May 26, 2026 at 4:11 pm

    Since there is no accepted answer yet: using multiple object managers is quite simple using RestKit.

    From the Wiki (Using Multiple Base URLs (and Multiple Object Managers):

    The first object manager you create will be the shared singleton
    RestKit uses by default. But by creating additional object managers,
    you can pull from their BaseURLs as needed, just be sure to retain
    these new managers.

    RKObjectManager *flickrManager = 
        [RKObjectManager objectManagerWithBaseURL:flickrBaseUrl]; // <-- shared singleton
    RKObjectManager *foursquareManager = 
        [[RKObjectManager objectManagerWithBaseURL:foursquareBaseUrl] retain]; // <-- you must retain every other instance.
    

    Depending on your application, you may want to put this second object
    manager in a more accessible place, like a retained property on the
    AppDelegate, so that it’s easy to pull from as needed.
    In the event that you need to differentiate between the results from
    your two (or more) object managers, simply set an identifier in the
    userData for the queries.

    - (void)someAction(id)sender {
            // .......
            RKObjectLoader* loader = [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/whatever" delegate:self];
            loader.userData = @"foursquare";
            // or do this, if you need a number instead of a string
            loader.userData = [NSNumber numberWithInt:1234];
            // .......
        }
    
    //Then when the delegate comes back you can cast it into a string or number as appropriate:
    - (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
        // .......
        NSString* source = (NSString*) objectLoader.userData;
        // or, if you did the NSNumber instead:
        NSNumber* source = (NSNumber*) objectLoader.userData;
        // .......
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am testing out a WCF service which is running on the same machine
I'm currently testing out retrieving json from jquery. The service url is: http://imgsvc.heroku.com/images In
We are testing out playframework from a port of a few pages of our
I'm testing out the Reactive Extensions (main branch from NuGet) and I'm having some
I'm just testing out saving to a file from a servlet, and I want
I have been testing out a few different xml editor/viewers and I can't seem
I'm testing out the PostgreSQL Text-Search features, using the September data dump from StackOverflow
I've had some bizarre results from queries I've been testing out with the DATE
I have been testing out some code and I need to load day view
I am having trouble testing out push notifications using the C2DM service. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.