title: count elements inside id<NSFastEnumeration>
body: <p>I have an <code>id&lt;NSFastEnumeration&gt;</code> object. I want to count the elements inside the object. How can that be achieved?</p>
  
  <p>The only method NSFastEnumeration implements is:</p>
  
  <pre><code>- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
  </code></pre>
  
  <p>This method returns the count I am looking for, but as I do not want to really enumerate the objects I wonder, what I could safely pass in as arguments. Would it be OK to just pass nil,nil,0? If not, what should I pass?</p>
  
  <p>The Background:</p>
  
  <p>I want to create an NSArray of the return values of a function, which I want to call with every element in the given collection. I want an Array of the results of enumerating a collection with a function.</p>
  
  <pre><code>id&lt;NSFastEnumeration&gt; enumeratable = someObject;
  NSMutableArray* results = [NSMutableArray arrayWithCapacity:(#Fill in count here#)];
  for (id object in enumeratable) {
      [results addObject:callFunctionOnObject(object)];
  }
  </code></pre>
  
  <p>AS you can see I only need the count to optimize Array initialization. I am pretty aware that I could use <code>NSMutableArray* results = [NSMutableArray array];</code> instead.</p>