Storage folder for video files and video "description" files in iOS - Apple Guidelines [closed]

StackOverflow https://stackoverflow.com/questions/15799518

  •  01-04-2022
  •  | 
  •  

Question

Currently I'm developing an app which will download some videos from a "computer device". These videos will be played in the app -> for proper sync. another file is needed (each video has its coresponding file). I have done some research on where should I store this... but there is no certain anwser (at least for me at this point).

Read this Guide to some point

I assumed the "/cache" folder is suitable? Which folder should I use in this case? I want the video to be playable in an "offline" situtaion. These videos can "weight" a little thus I don't want any iCloud sync for them.

Was it helpful?

Solution

While items in the caches directory do not get backed up to iCloud they can be purged by the system if under pressure to reclaim disk space. You could potentially store it in the users documents directory if it's "user generated" data.

An appropriate place to store downloaded content that your app needs offline would be the Application Support directory (Library/Application Support).

NSArray *appSupportURLs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
NSURL *applicationSupportDirectory = appSupportURLs[0];

You should also set attributes on files located elsewhere (Application Support, Documents, etc.) if you do not want them to be backed up. You can find more on it here: http://developer.apple.com/library/ios/#qa/qa1719/_index.html

OTHER TIPS

Use NSCachesDirectory. It won't be backed up in iTunes or iCloud.

NSArray *cachedirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachedir = cachedirs[0];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top