0

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?

Community
  • 1
  • 1
SirRupertIII
  • 11,945
  • 20
  • 70
  • 117

2 Answers2

1

Any format. iOS writeToPath: does not read the extension. You can even make up weird file names.

Take the codes from your reference question as example,

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

[myArray writeToFile:filePath atomically:YES];

the FILE_NAME could be in any ASCII values.

Raptor
  • 51,208
  • 43
  • 217
  • 353
1

The writeToFile of an array object creates a property list file. So, while you can use whatever extension you want, it's generally good style to use the plist extension.

Rob
  • 392,368
  • 70
  • 743
  • 952