How do I store an NSMutableArray to Disk on an iPhone app for later retrieval?
views:
100answers:
2
+2
A:
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.
Vladimir
2010-02-02 14:15:49
+2
A:
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];
Diederik Hoogenboom
2010-02-02 14:16:57