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 9316271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:34:30+00:00 2026-06-19T02:34:30+00:00

I am looking for a good tutorial on using the NSURLConnection Asynchronous request. I

  • 0

I am looking for a good tutorial on using the NSURLConnection Asynchronous request. I have been looking around in stackoverflow and Google but could not find one. This can be a duplicate of zillions of questions like this here. But please direct me to the correct tutorial, I have used ASIHTTPRequest before, but I have not used the Apple provided library before.

  • 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-06-19T02:34:31+00:00Added an answer on June 19, 2026 at 2:34 am

    I would provide you with one written myself, however I would HIGHLY recommend using AFNetworking, it’s a wrapper above the NSURLConnection / NSURLRequest system that has a much cleaner flow, you can also use basic NSURLRequests / Connections with this, along with regular NSOperationQueues. The library also uses cocoa pods, and to be honest you really can’t get much cleaner then that.

    NSOperationQueue *mainQueue = [[NSOperationQueue alloc] init];
    [mainQueue setMaxConcurrentOperationCount:5];
    
    NSURL *url = [NSURL URLWithString:@"http://192.168.0.63:7070/api/Misc/GetFuelTypes"];
    
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
    
    [request setHTTPMethod:@"GET"];
    [request setAllHTTPHeaderFields:@{@"Accepts-Encoding": @"gzip", @"Accept": @"application/json"}];
    
    [NSURLConnection sendAsynchronousRequest:request queue:mainQueue completionHandler:^(NSURLResponse *response, NSData *responseData, NSError *error) {
        NSHTTPURLResponse *urlResponse = (NSHTTPURLResponse *)response;
        if (!error) {
            NSLog(@"Status Code: %li %@", (long)urlResponse.statusCode, [NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
            NSLog(@"Response Body: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
        }
        else {
            NSLog(@"An error occured, Status Code: %i", urlResponse.statusCode);
            NSLog(@"Description: %@", [error localizedDescription]);
            NSLog(@"Response Body: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
        }
    }];
    

    The mainQueue object is used for routing requests and managing how many can be sent at once. This can be used in many ways, I tend to use them for categorized request (Authentication, Main, Upload Queue)

    once inside the block you build a local NSHTTPURLResponse using the returned response. This is needed if you want the status code returned. (doesn’t exist in the standard NSURLResponse object)

    responseData is the data that can usually be converted right to a string or run through a deserializer to obtain human readable data.

    Pretty simple explanation, delegates get you in trouble if you have no idea how to manage multiple requests from the same object (probably why I prefer blocks) 🙂

    Like always delegates or blocks you want to trigger your UI to update after you receive the response, but not be held back waiting for the request to complete, if you were loading data into a table you would call the request on load and supply some form of progress hud telling them a request is being made, once the data is received you remove the hud and reload the table data. HUDs MUST be called on the main thread so you will definitely need to handle that, I usually just build extensions and use performSelectorOnMainThread, however a better way might be to wrap your function in dispatch_async and call you’re hud show / hide code outside of that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading up on WCF and was looking for a good tutorial
I am looking and have been looking for a good example or tutorial on
Looking for a good tutorial on how to update a mysql database using a
I've been looking for a while to find a good tutorial with code example
I am looking for a good tutorial on XML pull processing (e.g. StAX) using
I have scoured the internet looking for a good tutorial or posting about having
I have been looking at using JOGL to create some things and have been
I was looking at a good REST tutorial using Jersey . Down the page,
We have created a website using Drupal , but the problem ( good problem
I've been in, around, and through a good chunk of the internets looking for

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.