Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS where to locally save images which can be re-downloaded?

I'm currently writing some code which will download images from my web server for offline use, previously I store these in the Documents Folder however I have heard with iOS5 and iCloud developers should not be storing information in Documents which can be re downloaded again.

I've tried searching the documents this morning but can't seem to find the location I should use to store these images, I would also like to create my own sub folder in the /cache/ folder i.e. /cache/images

Any pointers would be great, I have found NSTemporaryDirectory() but not sure if this is the right location to use.

Thanks

like image 691
MonkeyBlue Avatar asked Oct 19 '11 07:10

MonkeyBlue


2 Answers

You can access the cache directory like this (further info here)

NSString *directory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];

The content of the temporary directory returned by NSTemporaryDirectory() can be removed at any time by the system, not the cache directory.

like image 58
jbat100 Avatar answered Nov 14 '22 18:11

jbat100


The main issue with using the documents directory is that this gets backed-up when users do iTunes syncing and also now with the cloud storage. You should only place user specific things in the documents directory, everything else which CAN BE EASILY REDOWNLOADED / CREATED should be in the cache directory.

like image 4
Simon Lee Avatar answered Nov 14 '22 17:11

Simon Lee