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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:26:27+00:00 2026-05-30T21:26:27+00:00

I have a little Mac application which should be able to post Data to

  • 0

I have a little Mac application which should be able to post Data to my web server which saves the data in a database. Now that’s the Code I have now:

NSData *postData = [urlString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString:@"http://..."]];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];
    NSURLConnection * connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if (connection) NSLog(@"Done");

And it works fine. But now I want to check whether the data was correct (and stored in the database) or something (like eMail) is wrong. The PHP file prints e.g. “email incorrect” out if the E-Mail is not correct.
But how can I fetch this data (which PHP prints out) in Xcode that the App knows whether it was successful or not?

Thanks for answers!

  • 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-30T21:26:29+00:00Added an answer on May 30, 2026 at 9:26 pm

    Implement the delegate method for the NSURLConnection,


    – (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response.

    This method is called by the app when the request finishes. You can access response data using the ‘response’ parameter.

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
    

    Then just convert the ‘data’ parameter into a string using:

    NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    

    Then you can search the response for whatever string you want, e.g., “email incorrect”.

    PS: I generally don’t use NSURLConnection/NSURLRequest for HTTP requests, I’d recommend you check out ASIHTTPRequest for really simple HTTP requests/connections.

    Hope this helps.

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

Sidebar

Related Questions

I'm writing a new document-based cross-platform chemistry application (Win, Mac, Unix), which saves files
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have little question about how web browser retrieve webpage? I know this User
i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I've been using python for years, but I have little experience with python web
I am working on a java application that targets both mac and PC. Recently
I have an iPhone app that publishes through Bonjour. The Mac counterpart works, they
I have a little program that I want to make open automatically when my
I have a question, I do some iphone application and now I want to
I'm working on a project in Ruby right now that is essentially a web-app.

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.