Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When are files from NSCachesDirectory removed?

Tags:

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?

like image 350
esilver Avatar asked Jul 29 '11 22:07

esilver


2 Answers

Our experience is that this folder gets cleared on app updates. It would be nice to know when exactly this folder is a candidate for being cleared. The docs describe this folder as

location of discardable cache files (Library/Caches)

The NSDocumentDirectory will not be cleared on app updates but be careful using this folder since iOS 5 now uses this folder for backing up in iCloud and your app will likely be rejected if you use this directory to store anything other then user generated content.

like image 134
Chase Avatar answered Sep 27 '22 19:09

Chase


Anything which is in Library folder will NOT be deleted by the iOS during App Update.

Please check following documentation from Apple which mentions:

When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation. Files in the following directories are guaranteed to be preserved during the update process:

Application_Home>/Documents

Application_Home>/Library

Although files in other user directories may also be moved over, you should not rely on them being present after an update.

Here is the link to this documentation: http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTuning/PerformanceTuning.html#//apple_ref/doc/uid/TP40007072-CH8-SW10

Hope this helps.

like image 43
meetpd Avatar answered Sep 27 '22 19:09

meetpd