I have created some PDF files programatically, which i am storing into the devices memory using the following code >>>>
NSString *fileName = [NSString s
A good place to store private data is in ~/Library/Application Support/
, which is the folder used on the Mac for this purpose.
You can generate a path to this folder using:
NSString *appSupportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject];
You'll have to create the folder yourself the first time you use it, which you can do with:
if (![[NSFileManager defaultManager] fileExistsAtPath:appSupportDir])
{
[[NSFileManager defaultManager] createDirectoryAtPath:appSupportDir withIntermediateDirectories:YES attributes:nil error:NULL];
}
I wrote a simple library that makes this and all other useful iOS folders available as methods on NSFileManager: https://github.com/nicklockwood/StandardPaths
Just prefix the filename with a dot, as in .SampleTextFile.pdf
.
But the real solution is to not store the document in the NSDocumentDirectory
in the first place. You should create subdirectory in the NSLibraryDirectory
and store this stuff there. It also gets backed up and will not get purged like Caches
and tmp
, but the user cannot access it with iTunes.