HTTP HTTP REST requests / responses

I am very new to the iPhone SDK and have read many threads for integrating RESTful with iPhone. However, I am not wiser. You can help?

I have several PHP and a MySQL database row on the server. I POST 3 pieces of information from iPhone to PHP, which then meditates a bit and talks to the database.

It then returns 1, 2, or 3 values ​​depending on the POSTed information and the database.

In cases where I have a problem, we record and save the answer in a way that can then be analyzed on the iPhone.

I tried to return the data as a string (echo / return), an array, and finally XML. None of this works.

Does anyone have any thoughts on this or can point me in the right direction?

The ideal situation would be to end up with an array or 3 variables that I could check with the basic if statement.

Thanks in advance.

+3
source share
3 answers

Another alternative is to use the CocoaREST code available on github: http://github.com/sdegutis/CocoaREST . It was only recently released, but appears to be under active development and looks relatively easy to use.

EDIT: , - XML. : XML, XML plist. , XML - :

NSArray * myArray = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://example.com/xmlProducer"]];

(, NSDictionary, NSString .. URL-)

+4

JSON, Objective-C JSON framework. . JSON . json- NSArrays NSDictionaries .

. , json.org.

ObjectiveResource framework. Ruby on Rails, API RESTful, .

+3

Submit your data as plist (this is a subset of XML), which is easiest to parse.

+1
source

Source: https://habr.com/ru/post/1711430/


All Articles