Recommendations: What should I know before creating a web application API for an iPhone application?

I am starting to develop applications for the iPhone and I want to create an application that includes extracting data from a web application. I will develop the API using PHP and the Zend Framework. I have never created a public API before, nor an iPhone application that works with public data.

Here are some specific questions I have:

One of the things I will need to do is create a table view with data from the API.

  • What data format should the API return? XML, JSON, HTML? (I assume XML will be the easiest)

Say my API has a function fetchAllthat returns all the records in a database table, how can I format this data so that it works easily in my iPhone application?

# http://myapp.com/api/people/fetchAll
array(
    0 => 'John',
    1 => 'Sally',
    2 => 'Chris'
)

Update: . After a series of studies, I decided that (on the server side) I want to implement a RESTful API that returns JSON. Thus, my iPhone application will eventually become a REST client.

I also found this post, although it may be deprecated now: Creating RESTful Web Service Clients in Cocoa and Cocoa Click

+3
source share
3 answers

I would recommend using JSON.

JSON "fetchAll".

iPhone ( ASIHTTPRequest), JSON, , ​​ TouchJSON.

UPDATE

- JSON, NSURLConnection API. , iOS Recipes, , .

+5

Objective Resource. , , ActiveResource.

.

JSON :

{ "className" : { "key1" : "value1", "key2" : { "className2" : { "key1" : "value1" }}}}

, , , , .

+1

, REST + JSON. , , Github, NSURL Cocoa, .

XML-, Apple (plists), Cocoa. Ruby Python XML plist ( , plists, ).

On line 154, you can see how the property list loaded into the NSData instance is converted to its own NSDictionary.

http://github.com/akosma/iphonerestwrapper/blob/master/Classes/Wrapper.m#L154

0
source

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


All Articles