简体   繁体   English

如何将NSMutableArray存储到iPhone应用程序上的磁盘以供以后检索?

[英]How do I store an NSMutableArray to Disk on an iPhone app for later retrieval?

如何将NSMutableArray存储到iPhone应用程序上的磁盘以供以后检索?

NSArray (as well as other property list objects) provides easy saving/loading to the file - using following methods: NSArray(以及其他属性列表对象)可使用以下方法轻松保存/加载到文件:

+ (id)arrayWithContentsOfFile:(NSString *)aPath
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag

It might be useful to read Property List Programming Guide in Apple docs for more details. 阅读Apple文档中的《属性列表编程指南》以获取更多详细信息可能会很有用。

Use [NSKeyedArchiver archiveRootObject:myMutableArray toFile:path] 使用[NSKeyedArchiver archiveRootObject:myMutableArray toFile:path]

The folder to store the file at can be determined with: 可以使用以下方法确定存储文件的文件夹:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

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

相关问题 如何在iPhone应用程序中链接到App Store中的另一个应用程序? - How do I link to another app in the App Store in an iPhone app? 我如何存储用户在iPhone应用程序中选择的歌曲,然后检索并播放? - How can I store the song the user chose in my iPhone app and later retrieve it and play it? 如何将仅iPhone 4应用程序提交到App Store? - How do i submit a iPhone 4 only app to the App Store? 如何在iPhone设备文件系统中存储图像,以便以后我可以检索它并在我的应用程序中使用? - How can I store an image in the iPhone device file system so that later if I want I can retrieve it and use in my app? 如何部署iPhone应用程序(没有App Store)? - How do I deploy an iPhone application (without the App Store)? 如何实现“ iPhone App Store”样式标签栏? - How do I implement an “iPhone App Store” style tab bar? 如何对 iPhone 应用商店评论提出质疑? - How do I contest an iPhone app store review? iPhone:如何将高分存储到磁盘 - iPhone: How can I store a high score to disk 如何将整数值存储到iphone中的NSMutableArray中 - How to store integer value into an NSMutableArray in iphone 如何将NSRange存储在NSMutableArray或其他容器中? - How do I store an NSRange in a NSMutableArray or other container?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM