title: NSDirectoryEnumerator not looping; only processing one file at a time
body: <p>I'm writing a program that loops through and deletes all of the files in a folder. I'm using <code>NSDirectoryEnumerator</code> to do so. Problem is, the code only loops through once, handling one file, and then exists. I know this from NSLog statements. It works with single files and a folder with a single file in it.</p>
  
  <p>Here's the relevant code:</p>
  
  <pre><code>NSString *fileToNuke = filePath;
  NSLog(@"Incinerating %@", fileToNuke);
  [spinner startAnimation:self];
  #ifdef DEBUG
      NSLog(@"Incinerating %i times.", timesToIncinerate);
  #endif
  
  if ([fileManager fileExistsAtPath:filePath isDirectory:NULL] &amp;&amp; isDir) {
          NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:filePath];
          //NSString *file;
  
          //file = [directoryEnumerator nextObject];
          for (NSString *file in directoryEnumerator) {
              // Construct the path of the file to incinerate.
              NSString *finalPath = [NSString stringWithFormat:@"%@/%@", filePath, file];
  #ifdef DEBUG
              NSLog(@"%@", finalPath);
  #endif
  
              if (!incinerate(timesToIncinerate, [finalPath cStringUsingEncoding:(NSASCIIStringEncoding)], (int)eraseFile, useNonBlockingRandom, incinerateCallback)) {
                  [spinner stopAnimation:self];
                  erasing = NO;
                  break;
              }
              [spinner stopAnimation:self];
              erasing = NO;
  
              //file = [directoryEnumerator nextObject];
          }
      } else if (!isDir) {
          if (!incinerate(timesToIncinerate, [fileToNuke cStringUsingEncoding:(NSASCIIStringEncoding)], (int)eraseFile, useNonBlockingRandom, incinerateCallback)) {
              [spinner stopAnimation:self];
          }
          [spinner stopAnimation:self];
          erasing = NO;
  }
  
  // Tell the application waiting on the main thread to finish up with our task by notifing the user of
  // our completion.
  [self performSelectorOnMainThread:@selector(finishIncineration) withObject:nil waitUntilDone:YES];
  </code></pre>
  
  <p>I suspect it has something to do with how my <code>while</code> loop is being set up, but I welcome any suggestions. I just <em>know</em> I'm doing something stupid...</p>