title: unrecognized selector sent to instance - trying to check a uilabel text value in a view
body: <p>Up front, let me just say that I know the code I'll be showing below is probably inefficient, but I'm doing this "the hard way" because that's usually how I get things to stick when I'm learning...</p>
  
  <p>I've created a class that I'm calling at runtime and within that is a label (I'll be adding more labels dynamically, etc.) When I check the container that will hold these views, I first check to see if there are any other views within it already. If not, I add the view directly. If there are other views already in there, I need to check that it won't put two of the same item in there. Since these are based on a single class, my current line of madness is to use the "headerLabel" outlet I've set up in the xib for this class. So...</p>
  
  <p>In PhysicalExamDetailsNoteItem.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface PhysicalExamDetailsNoteItem : UIViewController {
      IBOutlet UILabel *headerLabel;
  }
  
  @property(nonatomic, retain)UILabel *headerLabel;
  
  @end
  </code></pre>
  
  <p>In PhysicalExamDetailsNoteItem.m, I add: @synthesize headerLabel; after @implementation.</p>
  
  <p>In ViewController.m:</p>
  
  <pre><code>#import "PhysicalExamDetailsNoteItem.h"
  
  // ... And after a long list of code-based view setup, I call a method that includes the following ... //
  
              if([[physExamDetailsNoteItems subviews] count] &gt; 0)
          {
              NSLog(@"More than one item already exists in the container, check preexisting items for %@ to eliminate duplication...", sender.currentTitle);
              for (PhysicalExamDetailsNoteItem *subview in [physExamDetailsNoteItems subviews]) {
                  NSLog(@"subview.headerLabel.text = %@", subview.headerLabel.text);
                  if (subview.headerLabel.text != sender.currentTitle) {
                      NSLog(@"%@ doesn't exist in the container, add it as a new item...", sender.currentTitle);
                      PhysicalExamDetailsNoteItem *noteItem;
                      noteItem = [[PhysicalExamDetailsNoteItem alloc] initWithNibName:@"PhysicalExamDetailsNoteItem" bundle:[NSBundle mainBundle]];
                      [physExamDetailsNoteItems addSubview:noteItem.view];
                      noteItem.headerLabel.text = sender.currentTitle;
                  }
              }
          }
          else
          {
              NSLog(@"No items exist in the container, add a new item...");
              PhysicalExamDetailsNoteItem *noteItem;
              noteItem = [[PhysicalExamDetailsNoteItem alloc] initWithNibName:@"PhysicalExamDetailsNoteItem" bundle:[NSBundle mainBundle]];
              [physExamDetailsNoteItems addSubview:noteItem.view];
              noteItem.headerLabel.text = sender.currentTitle;                
          }
  </code></pre>
  
  <p>I'm getting the error at this section:</p>
  
  <pre><code>PhysicalExamDetailsNoteItem *subview in [physExamDetailsNoteItems subviews]) {
                  NSLog(@"subview.headerLabel.text = %@", subview.headerLabel.text);
  </code></pre>
  
  <p>I have the headerLabel outlet rigged from the File's Owner object to the label view within IB, and when the enclosing method runs the if condition for the first time, it uses the else clause and populates my container view and changes the label text just as I want it to, but once it is called again and looks for the headerLabel for a comparison, it bails and I get:</p>
  
  <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView headerLabel]: unrecognized selector sent to instance 0x4b17470'</p>
  
  <p>Thanks in advance!</p>