title: When is the iPhone app cache is cleared?
body: <p>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. </p>
  
  <p>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)</p>
  
  <pre><code>    NSFileManager *fm = [NSFileManager defaultManager];
      NSString *directory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
      NSError *error = nil;
      BOOL success = [fm removeItemAtPath:[NSString stringWithFormat:@"%@%@", directory, currentEntry.audioFileURL] error:&amp;error];
      if (!success || error) {
          // it failed.
          NSLog(@"it failed to delete!!! %@ %@", error, [error userInfo]);
      } else {
          NSLog(@"Deleted... yipee... !!!");
      }
  </code></pre>