title: for loops - Object type disregarded?
body: <p>I sometimes like to organize IB elements into <code>NSArray</code>s primarily to help me organize my elements. Most often, different classes of objects make it into the same array with each other. While this <em>is</em> a convenient way of organization, I can't seem to wrap my head around why if I have an array like this:</p>
  
  <pre><code>NSArray *array = [NSArray arrayWithObjects:((UITextField *)textField), ((UISegmentedController *)segmentedController), nil];
  </code></pre>
  
  <p>Why I get "Does not respond to selector" messages when I put a <code>for</code> loop like this:</p>
  
  <pre><code>for (UITextField *text in array) {
      [text setText:@""];
  }
  </code></pre>
  
  <p>The <code>for</code> loop seems to be passed objects that are not of class <code>UITextField</code>.</p>
  
  <p>What is the point of declaring the object's class if all objects in the specified array are passed through the loop?</p>
  
  <p><strong>EDIT</strong> Just for reference, this is how I'm handling it as of now:</p>
  
  <pre><code>for (id *object in array) {
      if ([object isMemberOfClass:[UITextField class]]) {
          foo();
      } else if ([object isMemberOfClass:[UISegmentedController class]) {
          bar();
      }
   }
  </code></pre>