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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:50:03+00:00 2026-05-15T10:50:03+00:00

I would like to ask about the button and the url post method in

  • 0

I would like to ask about the button and the url post method in iPhone application.

In my program, I want the user to click a button, and then a url will be called by POST method. For the url, it may need to redirect to somewhere (302 or 303) etc and final is 200.

I have complete the button and the success page, however, I don’t know how to use the objective-C library. I found lots of reference of this forum, but I don’t understand what the code means. Can anyone help me?

The following is a question which I believe related to the question.
Invoking a http post URL from iphone using .net web service

Thank you very much.

  • 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-15T10:50:04+00:00Added an answer on May 15, 2026 at 10:50 am

    If you’re okay with blocking the thread you’re making the request on, this is just about as simple as it gets.

    NSString *postBody = [NSString stringWithFormat:@"param1=%@&param2", param1value, param2value];
    NSData *postData = [postBody dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:targetURL];
    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setHTTPBody:postData];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    

    A few caveats:

    • This will perform a synchronous (blocking) request, so either do it on a background thread or look into using the NSURLConnection delegate methods.
    • POST data must be URL-encoded, so you may need to do some preprocessing of your parameter values.
    • Redirects will occur automatically until a 200 OK or an error is encountered.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing the iPhone application and I would like to ask about the
I would like to ask a question. Now i'm training about iPhone Programming. I'm
I would like to ask about the available (free or not) Static and Dynamic
I would like to ask you about regular expressions preg_match have outlined below. I
I would like to ask you about some advices about this code. It works,
i would like to ask a question about @UsesJAXBContext annotation in jax-ws. I try
I have been reading about unsafePerformIO lately, and I would like to ask you
I am currently testing this environment and would like to ask about the best
sorry for any inconveniece caused. Would like to ask about database or rather databinding
I want to ask a question about the iPhone address book. I am writing

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.