Search code examples
objective-ciosios4cachingios5

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


Solution

  • 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.