I am working on an application that allows users to record voice (among other things) in the application’s Documents folder. But when I record the voice, I write to the application’s cache directory, and then after the user says “OK, save this”, then I go to him in the “Documents” folder. So far, it all works. But if I try to delete the data file in the cache, or when I try to move it, I have problems.
So my question is: will I just leave the data in the cache so that iOS processes it or do I need to manually delete the files in the cache. If so, how will I do it. This is the code that I still have (which does not 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) {
NSLog(@"it failed to delete!!! %@ %@", error, [error userInfo]);
} else {
NSLog(@"Deleted... yipee... !!!");
}