将 NSMutableArray 保存到 plist 中?
我读过 plist 可能是最好的方法,但我似乎找不到任何示例、帖子等来说明如何做到这一点?
所以基本上:当应用程序关闭时,如何将 NSMutableArray 保存到 plist 文件,以及如何再次恢复它?
Possible Duplicate:
iOS: store two NSMutableArray in a .plist file
In the app I'm working on I have a bunch of "Registration" objects that contain some strings,dates and integers.
All of these objects are stored in a NSMutableArray when they're created, and I now want to save this array in someway, so that when the user closes the app etc., the content can be stored and restored when app opens again.
I've read that plist is probably the best way to do so, but I can't seem to find any examples, posts etc. that show how to do it?
So basicly: How to I save my NSMutableArray to a plist file when app closes, and how to restore it again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSMutableArray 有一个方法可以做到这一点,如果你确切知道将其保存到哪里:
或者你可以使用 NSUserDefaults:
NSMutableArray has a method for doing this, if you know exactly where to save it to:
Or you can use NSUserDefaults: