title: How does Fast Enumeration (looping) work in Objective-C? (ie: for (NSString *aString in aDictionary)...)
body: <p>I'm working on implementing a customized searchBar for a fairly complex table and have come across this code pattern AGAIN. This is a sample from the Beginning iPhone Development book:</p>
  
  <pre><code>- (void)handleSearchForTerm:(NSString *)searchTerm
   {
  NSMutableArray *sectionsToRemove = [[NSMutableArray alloc] init];
  [self resetSearch];
  
  for (NSString *key in self.keys)
    {
      NSMutableArray *array = [self.names valueForKey:key];
      NSMutableArray *toRemove = [[NSMutableArray alloc] init];
      for (NSString *name in array)
      {
          if ([name rangeOfString:searchTerm
                        options:NSCaseInsensitiveSearch].location == NSNotFound)
              [toRemove addObject:name];
      }
  
      if ([array count] == [toRemove count])
          [sectionsToRemove addObject:key];
      [array removeObjectsInArray:toRemove];
      [toRemove release];
    }
  [self.keys removeObjectsInArray:sectionsToRemove];
  [sectionsToRemove release];
  [table reloadData];
  }
  </code></pre>
  
  <p>The part I'm curious about is the "for (NSString *name in array)" section. What is this doing exactly? It seems to create a string for every item in the array. Also, how does this work with dictionaries?</p>
  
  <p>Thanks!</p>