Speed: XML vs. NSUserDefaults

心不动则不痛 提交于 2019-12-12 02:12:48

问题


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..


回答1:


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.




回答2:


You should consider using a SQLite database, or even better CoreData to manage your library information.



来源:https://stackoverflow.com/questions/7215473/speed-xml-vs-nsuserdefaults

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!