Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should my application store large number of PDF files on iOS?

I am writing an iOS iPad app that will download several hundred large PDF files from the web and cache them on the iPad for offline use.

Where is the best place to store them on the iPad? The local file system, core data, or some other place? I am planning to use core data for an indexing and search mechanism (using thumbnail images etc), and will only access the PDF docs when a user specifically requests the full document.

like image 809
whatdoesitallmean Avatar asked Oct 05 '12 17:10

whatdoesitallmean


1 Answers

The best place to do so is either the Documents directory or the Cache directory. Documents in the Documents directory are supposed to be user-generated content, so I believe this is not what you're looking for.

Instead, I think you should use the Cache directory, which you can access using this method :

- (NSString *)cacheDirectory {
{
    NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *path    = [pathList objectAtIndex:0];
    return path;
}

Note that the Cache directory can be emptied by the system if you don't have enough space on the device. In my experience this almost never happens, but you might want to store your documents in a subdirectory of the Library directory other than Cache if you want to be absolutely, absolutely sure that the files never ever get deleted.

In this case, you have to set the do not backup flag on both the directory and the files, or else your app will be rejected.

See the Apple guidelines (requires a developper account) for official information.

like image 121
F.X. Avatar answered Sep 18 '22 00:09

F.X.