How should I architect my iPhone app to talk to my website?

前端 未结 6 994
面向向阳花
面向向阳花 2020-12-22 22:58

I\'m planning my first iPhone app and I\'d like to get some inputs as to how to build it, right from the start. The iPhone app is being built to be paired with a public faci

6条回答
  •  佛祖请我去吃肉
    2020-12-22 23:52

    I would do this like I have done with a lot of AJAX web-page stuff. i.e.:

    1. Have a URL on your server side package the information to be transmitted into XML format. (This can be through a CGI/PHP script or whatever). Your transmitting XML in the message body - so it's easy to human read and debug with a standard web browser.

    2. Use the standard iPhone NSXMLParser methods to parse out the individual data fields from the XML doc, and write it back to your database. This method is equiped to both fetch the data from a URL and parse it in one call - like:

    NSURL *xmlURL = [NSURL URLWithString:@"http://www.example.com/livefeed.cgi"];
    NSXMLParser *myParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
    
    1. Walk through the data hierarchy with the NSXMLParser methods and populate your database accordingly.

提交回复
热议问题