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
?
Asked
Active
Viewed 95 times
0

Community
- 1
- 1

SirRupertIII
- 12,324
- 20
- 72
- 121
2 Answers
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
- 53,206
- 45
- 230
- 366
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
- 415,655
- 72
- 787
- 1,044