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

  • Home
  • SEARCH
  • 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 6068225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:41:33+00:00 2026-05-23T09:41:33+00:00

I want help making multiple web service calls on the same view controller. Is

  • 0

I want help making multiple web service calls on the same view controller. Is there a way I can do it.

Thanks

  • 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-23T09:41:34+00:00Added an answer on May 23, 2026 at 9:41 am

    There are several ways to solve this problem and each depends on your circumstance. The first would be to use multiple copies of + (id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error method of NSString. So if you wanted to get the contents of some URL you could use the following code

    NSURL* url = [NSURL urlWithString:@"http://www.someUrl.com/some/path"];
    NSString* urlContents = [NSString stringWithContentsOfURL:url encoding:NSUTF8Encoding error:nil];
    NSURL* anotherUrl = [NSURL urlWithString:@"http://www.anotherUrl.com/some/path"];
    NSString* anotherUrlContents = [NSString stringWithContentsOfURL:anotherUrl encoding:NSUTF8Encoding error:nil];
    

    The issue with this approach is that it will block whatever thread you call that on. So you can either call it in a thread or use one of the other approaches.

    The second approach is to use NSURLConnection. This uses delegates to handle the process in an event driven fashion. There is a good summary of that approach here. But you will also need to differentiate between requests in the delegate methods. For example

    -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *) response
    {
        if(connection == connection1)
        {
            //Do something with connection 1
        }
        else if(connection == connection2)
        {
            //Do something with connection 2    
        }
    }
    

    The third approach is to use some kind of wrapper class that handles http requests at a higher level. Personally I like ASIHTTPRequest. It can handle requests synchronous, asynchronous using delegates, and asynchronous using blocks.

    - (IBAction)grabURLInBackground:(id)sender
    {
       NSURL *url1 = [NSURL URLWithString:@"http://example.com/path/1"];
       ASIHTTPRequest *request1 = [ASIHTTPRequest requestWithURL:url1];
       request1.delegate = self;
       request1.didFinishSelector = @selector(request1DidFinish);
       [request1 startAsynchronous];
    
       NSURL *url2 = [NSURL URLWithString:@"http://example.com/path/2"];
       ASIHTTPRequest *request2 = [ASIHTTPRequest requestWithURL:url2];
       request2.delegate = self;
       request2.didFinishSelector = @selector(request2DidFinish);
       [reques2 startAsynchronous];
    }
    
    - (void)request1DidFinish:(ASIHTTPRequest *)request
    {
       NSString *responseString = [request responseString];
    }
    
    - (void)request2DidFinish:(ASIHTTPRequest *)request
    {
       NSString *responseString = [request responseString];
    }
    

    This example shows you how to do an asynchronous request using blocks as the callbacks intsead of delegate methods. Note that this can only be used in iOS 4.0 and greater since it uses blocks. But ASIHTTPRequest in general can be used on iOS 3.0 and greater without blocks.

    - (IBAction)grabURLInBackground:(id)sender
    {
       NSURL *url = [NSURL URLWithString:@"http://example.com/path/1"];
       __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
       [request setCompletionBlock:^{
          NSString *responseString = [request responseString];
       }];
       [request startAsynchronous];
    
       NSURL *url2 = [NSURL URLWithString:@"http://example.com/path/2"];
       __block ASIHTTPRequest *request2 = [ASIHTTPRequest requestWithURL:url];
       [request2 setCompletionBlock:^{
          NSString *responseString = [request2 responseString];
       }];
       [request2 startAsynchronous];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want our app to show the online help page (so it's always up
I just want a simple tool that will help me quickly write scripts/packages that
I want a hyperlink on my main page to launch an HTML help page
I want to create extra rules in FXCop. Custom Rules to help ensure specific
I hope someone could help me on this. I want to add a month
I want to move the form title, icon and close, and help buttons from
i need some help with inserting multiple rows from different arrays into my database.
It gives me the creeps,i'm done, i need some help here, i reverted multiple
I'm currently making a IRC bot in Java (I know, there are frameworks out
this en.wikipedia.org/wiki/Hot_swapping#cite_note-1 says that VS can do it with the help of its debugger.

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.