views:

98

answers:

1

I have an app that will need to cache some images.

I have read some documentation about caching, and the logical thing to do is to cache my images within the Library/Caches directory within my app's sandbox.

I understand that the reason for storing caches images here are:

  • Library/Caches isn't backed up by iTunes
  • Library/Caches is cleared periodically by the OS

That second point is what I'm questioning...

  • Is this true?
  • Does the OS clear the caches directory automatically?
  • Will I need any of my own logic to detect if the cache is too big and to clear the oldest items?
+1  A: 

I found this in the documentation:

Use this directory to write any application-specific support files that you want to persist between launches of the application. Your application is generally responsible for adding and removing these files. However, iTunes removes these files during a full restore of the device so you should be able to recreate them as needed. To access this directory, use the interfaces described in “Getting Paths to Application Directories” to get the path to the directory. In iPhone OS 2.2 and later, the contents of this directory are not backed up by iTunes.

http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html

darren
I see, so I'll have to keep an eye on the cache and purge it if it gets too large...That is unless it's acceptable to place the images in Library/tmp? They're not exactly critical and can be re-downloaded very easily on demand.
Jasarien