如何将NSMutableArray存储到iPhone应用程序上的磁盘以供以后检索?
NSArray (as well as other property list objects) provides easy saving/loading to the file - using following methods:
+ (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.
Use [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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.