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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:58+00:00 2026-05-27T17:13:58+00:00

Which options do I have to retrieve the data from PHP to Objective-C? Until

  • 0

Which options do I have to retrieve the data from PHP to Objective-C?

Until now, I did it like:

NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost/~username/Proyect/LogIn.php"]];
[request setHTTPMethod:@"POST"];

NSString *post =[[NSString alloc] initWithFormat:@"Account=%@&Password=%@&submit=",[account stringValue],[password stringValue]];
[request setHTTPBody:[post dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString *data=[[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];

The problem with this is that the data (I mean the variable data in the code above), when I print (NSLog) it’s value, it prints everything that was printed (echo) in my PHP file, (not the return value of the PHP file, as it has to be). Is there any way to return data, for example let’s say like an object, or at least a primitive variable (boolean, strings, int. . . ), without using the echoes?

If anyone has any good and complete tutorial about how to handle data from web services, it would be helpful.

P.S.: I’m trying to program a MMORPG, I rather spend my time programming video games than playing them, that’s why I would like to retrieve the data as an object (character for example).

  • 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-27T17:13:58+00:00Added an answer on May 27, 2026 at 5:13 pm

    Output your PHP object with JSON using echo json_encode($object). You fetch the data like you are, and then use NSJSONSerialization “decode” the JSON that PHP encoded:

    id json = [NSJSONSerialization JSONObjectWithData: data options:NSJSONReadingMutableContainers error: nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have got loads of options for php + MySQL + Apache combo... Which
I have an iPhone app which gets a response from a php file. This
Which makes website more speedy retrieve data from a MySQL Database or test value
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
I have a class on which I want to allow several (~20+) configuration options.
I have an ASP.Net page, which displays a list of options to the user.
I am using some pre-written JavaScript from polldaddy. They have a JavaScript option which,
I have a Queue with some data. If I want to retrieve 5 bytes
I'm using ajax to retrieve some data from the backend. I get the result
I have an application which is used for data analysis and I'm having a

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.