title: Delete all files and folder from a certain folder
body: <p>I have a /Documents/Images folder , in that folder are several other folders named after years , in those folders i have images.  I want to delete everything from the images folder ( including the folders and the images in these folders). </p>
  
  <p>I tried several code snippets but none delete the folders</p>
  
  <p>my method:</p>
  
  <pre><code>- (void) clearCache:(NSString *) folderName{
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
  NSString *documentsDirectoryPath = [paths objectAtIndex:0];
  NSFileManager *fm = [NSFileManager defaultManager];
  NSString *directory = [documentsDirectoryPath stringByAppendingPathComponent:folderName];
  NSLog(@"Removing items at path: %@",directory);
      NSError *error = nil;
  BOOL succes = [fm removeItemAtPath:directory error:&amp;error];
  
  /*for (NSString *file in [fm contentsOfDirectoryAtPath:directory error:&amp;error]) {
      //BOOL success = [fm removeItemAtPath:[NSString stringWithFormat:@"%@%@", directory, file] error:&amp;error];
      BOOL success = [fm removeItemAtPath:[directory stringByAppendingPathComponent:file] error:&amp;error];
      if (!success || error) {
          // it failed.
      }
  }*/
  </code></pre>
  
  <p>}</p>