title: NSFileManager and NSDirectoryEnumerator Crash?
body: <p>The code below crashes at <code>walker = [fileManager enumeratorAtPath:directory];</code>. The code executes OK on the first call to <code>refresh</code>, but crashes on the second (and subsequent) calls.</p>
  
  <p>Any ideas on what I might be doing wrong?</p>
  
  <pre><code>- (void)refresh
  {
      NSString* directory = nil;
      NSFileManager* fileManager = nil;
      NSDirectoryEnumerator* walker = nil;
  
      if(files == nil)
          files = [[NSMutableArray alloc] init];
      else
          [files removeAllObjects];
  
      ASSERT(files != nil);
      if(files == nil) goto EARLY_EXIT;
  
      fileManager = [[NSFileManager alloc] init];
      ASSERT(fileManager != nil);
      if(fileManager == nil) goto EARLY_EXIT;
  
      directory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
      ASSERT(directory != nil);
      if(directory == nil) goto EARLY_EXIT;
  
      ASSERT(directory != nil);
      walker = [fileManager enumeratorAtPath:directory];
      ASSERT(walker != nil);
      if(walker == nil) goto EARLY_EXIT;
  
      NSString* file;
      while((file = [walker nextObject]) != nil)
      {       
          BOOL isDirectory = YES;
          if([fileManager fileExistsAtPath:file isDirectory:&amp;isDirectory] &amp;&amp; !isDirectory)
              [files addObject:file];
      }
  
  EARLY_EXIT:
  
      //if(walker != nil)
      //  [walker release];
  
      if(fileManager != nil)
          [fileManager release];
  
      //if(directory != nil)
      //  [directory release];
  }
  </code></pre>