本文介绍了速度:XML与NSUserDefaults的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加载和存储(读取和写入)歌曲信息库,但我不知道哪种存储方法会更有效.最初,我将创建的NSArray存储到NSUserDefault中,以允许进行读/写访问.但是,在研究了iTunes如何存储其库信息之后,我考虑了从XML文件进行读取和写入.哪种方法更容易实现,更明智的使用速度/内存?任何帮助将不胜感激..

I'm attempting to load and store (read AND write) a library of song information, and I don't know which method of storage would be more efficient. Initially I stored an NSArray that I'd created to a NSUserDefault, which allows for read/write access. However, after looking into how iTunes stores its library information, I've considered reading and writing from an XML file. Which would be easier to implement and more effective speed/memory usage wise? Any help would be greatly appreciated..

推荐答案

NSUserDefaults仅用于首选项,而不用于保存大量数据.NSUserDefaults被保存为plist(显然是xml格式),因此读写速度应该没有任何差异.我建议您将信息保存在documents文件夹内的plist中.还有CoreData(另存为SQLite)或SQLite.与plists或NSUserDefaults相比,这两种方法都更难以实现.

NSUserDefaults is ment just for preferences, not for saving a lot of data. NSUserDefaults are being saved in a plist (xml format, obviously) so there shouldn't be any difference in reading and writing speed. I would recommend you to save the information in a plist inside your documents folder. Aswell there is CoreData (which is saved as SQLite) or SQLite. Both of it is more difficult to implement than plists or NSUserDefaults.

这篇关于速度:XML与NSUserDefaults的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 01:01