Alex Rivera | Logout

When are files from NSCachesDirectory removed?

Asked 2011-07-29T22:57:25.480
21

In what circumstances would files in the iOS NSCachesDirectory get removed? Obviously, delete and reinstall an application. What about application upgrade? What about low disk space conditions? Anything else?

Edit
Report

1 Answer

2

NSCachesDirectory can be deleted in cases of low memory

On iOS 5.0 and later, the system may delete the Caches directory on rare occasions when the system is very low on disk space. This will never occur while an app is running. However, you should be aware that iTunes restore is not necessarily the only condition under which the Caches directory can be erased.

more info

If you don't want your files to be deleted you have to store them in the Documents directory, but this way:

Use the "do not back up" attribute for specifying files that should remain on device, even in low storage situations. Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory. These files will not be purged and will not be included in the user's iCloud or iTunes backup. Because these files do use on-device storage space, your app is responsible for monitoring and purging these files periodically.

more info

answered 2012-07-31T11:33:35.687

Your Answer