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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:38:54+00:00 2026-05-15T15:38:54+00:00

I am writing an app that’s a very simple web service client. I have

  • 0

I am writing an app that’s a very simple web service client.
I have the following questions:
1. Is there a standard common way to write the web service consumption part so that it won’t interfere with the main GUI thread? Is it common practice to use the main thread considering the web request should take a very short time to complete (but never know)?
Any links to tutorials?
2. All examples I saw call the web service via GET. I need to POST the data to the web service.
Any known samples/tutorials that use POST?

  • 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-15T15:38:54+00:00Added an answer on May 15, 2026 at 3:38 pm

    If you’re using the iPhone’s built-in web request API, NSURLConnection, you run the request on the main thread but you run it asynchronously, with callbacks to a delegate as data is returned. This leaves the application responsive to user events. If the parsing or processing of the returned data takes too long to run on the main thread then you should run the NSURLConnection on the main thread, then hand off response data either incrementally or after the download is complete to a secondary thread for pure compute processing.

    It is possible to start NSURLConnections on a non-main thread but you’ll need to create a runloop on the non-main thread, and there are reports of random thread-safety bugs in the Apple libraries. If you really need to run the request itself on a non-main thread you can use the third party library ASIHTTPRequest, but you shouldn’t need to do this except in very specialized circumstances.

    Generating a POST request is straightforward with NSURLConnection:

        NSString * requestBody = @"format up your body here, which is often form-urlencoded";
    NSURL * nsurl = [NSURL URLWithString: @"http://example.com/post_request_receiver"];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:nsurl];
    // set appropriate content type here, usually application/x-www-form-urlencoded
        [theRequest addValue: @"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue: [NSString stringWithFormat:@"%d", [requestBody length]] forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [requestBody dataUsingEncoding:NSUTF8StringEncoding]];
    
    conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an auto update client. It's a very simple app that: 1)
I'm writing a very simple CRUD app that takes user stories and stores them
I'm writing a simple App Engine app. I have a simple page that allows
I am writing a simple Android app and have a database that will send
I'm writing an app that monitors the user's location. I have a CLLocationManager object
I am writing a simple business app that retrieves data from a server for
I have a very simple app running on heroku with nodejs and redis. It
I am writing a simple web app using Linq to Sql as my datalayer
I'm writing a very simple flash app (AS 2) to sign users up to
We are writing an app that will use T4 to generate Flex/Actionscript to compile

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.