开发者

Using core data with web services

I am a newbie in Xcode. I am developing an iPhone app where I need to send and receive data from a web service. And I need to store them temporarily开发者_Go百科 in my app. I don't want to use SQLite. So I wondering if I should use core data for this purpose. I read some articles but I still don't have a clear picture of How to do it, because I have used core data only with SQLite. I want to do the following things :

  1. How to receive table data from a web service?
  2. Have to perform certain calculations on those fields.
  3. How to send the data back in xml format to the server?

How do I convert the xml data into int, date or any other data type? And How do I store it in managed data objects?


You want to use an XML parser to turn the XML into other objects; I tend to recommend TouchXML for that.

You can use Core Data and an in memory store if you are not going to save the data as it will then create and manage all of the data objects for you and generally give you less code to write. However that depends on your app if it is worth it or not. Personally i use Core Data in every app that works with data.

As for sending data, you can use the same library that you used to consume the XML to produce XML. Most of them now days are bi-directional.


For a specific example of fetching XML from server and then storing on the device using core data take a look at Björn Sållarp's blog post on Core Data and UITableView. A drill-down application. Note this example makes use of NSXMLParser and not TouchXML.

I have also found [coredatalibrary xcode template][2] to be quite useful in getting started with a new Core Data project.

Also if you are adding custom logic to your managed objects take a look at rentzch's [mogenerator][3] which generates 2 classes _MyEntity and its subclass MyEntity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜