In my iPhone app I\'m caching the raw data of some compressed files to save loading time. But those files may change in an update.
Will iOS clear /Library/Caches for me
The caches directory will be purged if iOS is running out of space. If the user chooses "update all" from the app store options, it is likely that they will run out of space.
You should only store files in the Caches directory if they can be recreated by your app. From what I understand, the media player in iOS7 will only play videos stored in caches directory, and here's how I clear them manually (just in case):
-(void)deleteAllVideos
{
NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSFileManager* fileManager = [NSFileManager defaultManager];
NSArray *directoryContent = [fileManager contentsOfDirectoryAtPath:cachePath error:NULL];
NSError* error;
NSString* fullFilePath = nil;
for(NSString* fileName in directoryContent)
{
if([fileName hasSuffix:@".mp4"])
{
fullFilePath = [cachePath stringByAppendingPathComponent:fileName];
[fileManager removeItemAtPath:fullFilePath error:&error];
if(error)
{
DLog(@"Error: %@",error);
}
}
}
}