简体   繁体   English

Objective-c:如何存储大量数据(iOS RSS应用程序)

[英]Objective-c : How to store a large amount of data (iOS RSS application)

I'm currently working on a Google Reader application on iOS and I would like to know what is the best way to store all the previously downloaded data (which could go up to thousands of news) ? 我目前正在使用iOS上的Google阅读器应用程序,我想知道什么是存储所有以前下载的数据(可能会增加数千条新闻)的最佳方法吗? I heard of Core Data, is it the way ? 我听说过核心数据,是这样吗? Or would it be easier to store an XML or JSON file and to parse it ? 还是更容易存储XML或JSON文件并进行解析?

Thank you 谢谢

核心数据或直接使用sqlite。

Core Data is in general a good way to go for handling large amounts of data, esp with complex relationships. 通常,核心数据是处理大量数据(尤其是复杂关系)的一种好方法。

In this particular case however you can stand on the shoulders of giants. 但是,在这种情况下,您可以站在巨人的肩膀上。 NetNewsWire is a iOS RSS radar (that uses google reader), and it used Core Data for a while and switched away from it. NetNewsWire是一台iOS RSS雷达(使用Google Reader),它使用Core Data了一段时间,然后离开了它。 The then-author of NewNewsWire was kind enough to write why in http://inessential.com/2010/02/26/on_switching_away_from_core_data NewNewsWire的当时作者很友好,可以在http://inessential.com/2010/02/26/on_switching_away_from_core_data中写下原因

I don't think any of that would have changed, so unless your RSS reader is very different from NetNewsWire it will be faster if it avoids Core Data and uses sqlite (directly, or via some framework like FMDB). 我认为这不会改变,因此除非您的RSS阅读器与NetNewsWire完全不同,否则如果它避免使用Core Data并使用sqlite(直接或通过某些框架,例如FMDB),它将更快。 I'll also bet that you will be "faster to market" if you use Core Data and take the performance hit. 我还敢打赌,如果您使用Core Data并获得出色的性能,您将“更快地推向市场”。

(now the focus of your RSS program may be very different, and so maybe you will never need to do the equivalent of update newsItems set read = 1 where for 10,000 items or any of the other things where Core Data hinders more then helps -- if so, by all means run to Core Data) (现在您的RSS程序的重点可能大不相同,因此也许您将不需要做等同于将update newsItems set read = 1 where对于10,000项,或其他任何其他因Core Data阻碍更多的事情而提供的帮助-如果是这样,一定要运行到核心数据)

NOTE: things have changed a bit since this answer was written. 注意:自撰写此答案以来,情况有所改变。 iOS 8 has added some support for bulk operators that bypass some of this, see NSBatchUpdateRequest for example. iOS 8增加了对绕过其中一些操作的批量运算符的支持,例如,请参阅NSBatchUpdateRequest。 I don't have direct experience with it, and you would need to drop iOS 7 and prior support (or write the code twice, and only work well for large datasets on iOS 8+). 我没有直接的经验,您需要放弃iOS 7和先前的支持(或编写两次代码,仅适用于iOS 8+上的大型数据集)。 Also all the warnings about using "new" things apply ("not as well tested", "not as many places to turn to for help"), offset of course by it maybe being a perfect fit for your problem, and Oooo Shiny! 同样,所有关于使用“新”事物的警告都适用(“未经过充分测试”,“没有太多求助的地方”),当然可以抵消它可能完全适合您的问题,并且Oooo Shiny!

Use core data. 使用核心数据。 It's perfect for what you are needing. 非常适合您的需求。 Look up the documentation and there's plenty of sample code available (you can even start a new project in Xcode and select the core data option to have it populate the app delegate with all the required core data code for you. 查找文档,这里有很多示例代码(您甚至可以在Xcode中启动一个新项目,然后选择核心数据选项,使其为您提供所有必需的核心数据代码来填充应用程序委托。

Yes you are correct. 是的,你是对的。 Unless you have taken the time to learn some SQLite, XML, or JSON... using Core Data is by far the best and easiest option to implement. 除非您花时间学习一些SQLite,XML或JSON ...使用Core Data是迄今为止实现的最佳和最简便的选择。 It is created by Apple for Apple applications and operating systems. 它是由Apple为Apple应用程序和操作系统创建的。 There is very good documentation and sample code at www.developer.apple.com under Core Data. www.developer.apple.com的Core Data下有非常好的文档和示例代码。 Start here: Core Data Programming Guide on developer.apple.com 从这里开始: developer.apple.com上的《核心数据编程指南》

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM