I'm working on an app that lets users record voice (among other things) to the Documents directory of the app. But when I'm recording the voice, I'm recording to the caches directory of the app and then after the user says "Okay, save this one", then I'm coping it to the Documents directory. So far all these work. But if I try to delete the data file in cache, or when I try to move it, I get problems.
So my question is, shall I just leave the data in cache so that iOS will handle it or do I need to manually delete the files in cache. If so how would I go about doing it. This is the code I have so far (which doesn't work)
NSFileManager *fm = [NSFileManager defaultManager];
NSString *directory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
NSError *error = nil;
BOOL success = [fm removeItemAtPath:[NSString stringWithFormat:@"%@%@", directory, currentEntry.audioFileURL] error:&error];
if (!success || error) {
// it failed.
NSLog(@"it failed to delete!!! %@ %@", error, [error userInfo]);
} else {
NSLog(@"Deleted... yipee... !!!");
}
$(APP_WRAPPER)/Library/Caches
isn't backed up or restored, but it isn't automatically reaped, either. When it fails, what error are you getting? – Centuplicate