douxianxing5712 2012-08-23 12:57
浏览 65
已采纳

关于Iphone和Webserver通信的多个问题

Right now I'm in the middle of a project at college, regarding IPhone-Development. The project consists of a webserver with mysql database and multiple clients (IPhone Devices).

I'm struggling a bit with the basic cocept, which is the communication (receiving, sending data) between IPhone and Webserver.

I've set up an Webserver with a MYSQL-Database. I also have a PHP-Script that accesses the DB and writes the db-Data into an XML-File.

1)What would be the best way to proceed with the Client (IPhone)?

2)Is it possible to directly access a .php File and download the XML to the IPhone?

3) What will be downloaded to the IPhone? The whole XML-File or the XML-Content?

I would then go on to process the XML-File with a XML-Parser (preferably NSXMLParser).

4) How is it possible to store the received data persistently on the IPhone? NSMutableArray? This feature is required for offline mode if any data is added on the IPhone-device.

This brings me to my last question:

5) How do I send data back to the webserver? Or to be more specific, wich datastructure do I have to use to send data back to the webserver? What would be a reasonable way to do this? For example: creating a new XML-file and sending it back to the webserver?

Best Regards, Alex

  • 写回答

1条回答 默认 最新

  • drno94939847 2012-08-23 14:55
    关注

    Must the data protocol be XML? I'd opt for JSON as the data protocol! If it's feasible for you to use JSON then take a look at the lightweight SBJson framework. It's going to be much easier to use JSON over XML for iOS, believe me!

    To summarize on the other questions, regarding server communication etc.! Is it a mandatory precondition for you to write the networking code from scratch or are you allowed to use existing open frameworks for that? If you may use a framework then f.e. take a look at MKNetworkKit! It'll take away almost all the hassles that come with writing or incorporating own network code and it has JSON serialization/deserialization build in already!

    If not then go with NSURLConnection, NSURLResponse and probably some NSOperation/NSOperationQueue for asynchronous handling and have some fun! :-) And don't forget the Reachability.h/m from Apple! ;-)

    For data persistence on the device either go with CoreData, which is very powerful but mybe (regarding complexity) to much of overhead for your purpose. Or just store your stuff with/in NSUserDefaults!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画