plist 或字典存储
在 iOS 中存储多个词典的最佳方式是什么?
我希望能够将新词典保存到用户的手机上。有没有办法迭代 plist 中的字典,或者它应该是由字典数组组成的 plist?
plist 是执行此操作的最佳方法还是还有其他方法?
如何从 plist 加载字典数组并将其存储在应用程序中?我试图将当前的 plist 加载到数组中,但得到空值。
What is the best way to store a number of dictionaries in iOS?
I want to be able to save a new dictionary to the users phone. Is there a way to iterate through the dictionaries in a plist or should it be a plist consisting of an array of dictionaries?
Is plist the best way to do this or is there another way?
How would the array of dictionaries be loaded from the plist and stored in the app? I am trying to load a current plist into an array, but get null values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 writeToFile:atomically 写出字典。如果将它们写入目录,则可以循环遍历该目录中的文件。但不要忘记将它们放在可写目录中。
其他想法包括保存文件并将文件名保存在共享首选项中。
不过,如果我处于您的位置,我会查看 nanostore。我认为它会满足您的所有需求,而不会像核心数据那样陷入困境。
You can write a dictionary out using
writeToFile:atomically
. If you write them into a directory you can loop through the files in that directory. But don't forget to put them in a writable directory.Other ideas include saving the files out and saving the file name in the shared preferences.
However, if I were in your position, I would checkout nanostore. I think it will meet all your needs without being as bogged down as core data.