DennisW83
DennisW83

Reputation: 11

Which directory to save files to, according to Apple guidelines?

I am writing an app that will save a text file to the device, like a shopping cart.

So it will be needed only while using the app.

Now, there are many directorys in the tutorials around the web, but nobody says which directory I can save files into and pass Apple's guidelines.

On my device, I save the files to the NSDocumentDirectory like this:

NSArray *pfad = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *dokumente = [pfad objectAtIndex:0];

NSString *dateiname = [NSString stringWithFormat:@"%@/warenkorb.txt", dokumente];

Does anybody know if this will pass the review from Apple and be able to go to the App Store?

Upvotes: 0

Views: 320

Answers (2)

Jonah
Jonah

Reputation: 17958

See A Few Important Application Directories to choose an appropriate directory to store your files. In your case it sounds like you want to use tmp rather than Documents since there's not need for these files to persist between launches of the application or be backed up when the device is synched.

See Getting Paths to Standard Application Directories for the suggested way to locate those directories. In this case you probably want to use NSTemportaryDirectory.

Upvotes: 1

taskinoor
taskinoor

Reputation: 46037

Document directory is standard and will be accepted by Apple. But it might be better to use stringByAppendingPathComponent to form the full path.

NSString *dateiname = [dokumente stringByAppendingPathComponent:@"warenkorb.txt"];

Upvotes: 3

Related Questions