How do I store persistent data on my iOS app using

2019-02-19 18:05发布

I'm developing an iOS app that is going to parse XML from an RSS feed of events and display the details of each event on a table view. Each event has a title, a description (optional), a date and a time. I am able to parse the XML data using NSXMLParser; however, I am not sure how I should store the data and make it so that it persists after the app is closed.

I have read that I can use NSCoder to persist the data but I am not sure if this is the best route forward.

Does anyone have any ideas or suggestions as to what I could do?

Any help is appreciated.

1条回答
甜甜的少女心
2楼-- · 2019-02-19 18:46

You have several options for persisting data.

  • NSUserDefaults are meant for user settings - small amounts of data. They seem unsuitable for what you have in mind.
  • NSCoding is quite a good way to store structured data without the overhead of a database, yet it is slow in comparison to core data.

  • Core Data is Apples ORM, which is quite powerfull but not as easy to wrap your head around.

I answered a similar question recently, which goes into more detail regarding NSCoding with a complete example and some links for further reading.

查看更多
登录 后发表回答