Lloyd18
Lloyd18

Reputation: 1682

Best place to store application content

I have application, that operates with large amount of data (basically images), that downloaded from our server and should be available without internet connection.

I used to store them in <Application_Home>/Library/Caches directory, but after iOS update process all of them was deleted. This behaviour is unacceptable for me and now I'm looking for better place where I can store data and be sure they will not deleted by the system.

What is the best place to store this kind of data?

Upvotes: 0

Views: 90

Answers (2)

rckoenes
rckoenes

Reputation: 69499

The caches directory is what the name implies, as cache. Caches can be emptied and you should indeed re download the images. The documents directory is a better place to store these images, but you should store then with the skip iCould backup key on the file.

Just a small tip, always use either URLForDirectory:inDomain:appropriateForURL:create:error: or NSSearchPathForDirectoriesInDomains

Upvotes: 3

ksysu
ksysu

Reputation: 311

Only data in the documents directory isn't deleted by iOS:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;

Data in the documents are synchronized with the iCloud. If you have a lot of them you need to disable this option:

[urlOfImage setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];

Upvotes: 1

Related Questions