Monday, 26 August 2013

Which file format should I use to save an array to a file?

Which file format should I use to save an array to a file?

I am using the solution found here: save NSArray to file and I am just
wondering what type of file format I should save my array as. Can I just
use .txt?
Okay, I'll add my code, Hope people don't get mad that I am changing my
question... I am getting 0x00000000 for my retrieved boundaries array when
I do the following:
to save:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory
stringByAppendingPathComponent:@"boundaries"];
[array writeToFile:filePath atomically:YES];
to retrieve:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory
stringByAppendingPathComponent:@"boundaries"];
NSArray *boundaries = [NSArray arrayWithContentsOfFile:filePath];
Is something wrong with this? The array is full of correct data when I
save it.

No comments:

Post a Comment