title: How can I store UIButtons in an array?
body: <p>I have a method tied to four buttons.  I want to create an array containing each button, and later retrieve and interact w/ a button from the array.  The code I was tinkering with below.  When I try to get a button from the array and send it a message, it goes kablooie.  </p>
  
  <p>Any thoughts on what I'm doing wrong?</p>
  
  <p>Hack_DumpViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface Hack_DumpViewController : UIViewController {
      IBOutlet UIButton *redButton;
      IBOutlet UIButton *greenButton;
      IBOutlet UIButton *blueButton;
      IBOutlet UIButton *yellowButton;    
      NSArray *buttonMapping; 
  }
  
  - (IBAction) changeToYo:(id)sender;
  @property (nonatomic, retain) UIButton *redButton;
  @property (nonatomic, retain) UIButton *greenButton;
  @property (nonatomic, retain) UIButton *blueButton;
  @property (nonatomic, retain) UIButton *yellowButton;
  @property (nonatomic, retain) NSArray *buttonMapping;   
  
  
  @end
  </code></pre>
  
  <p>Hack_DumpViewController.m</p>
  
  <pre><code>#import "Hack_DumpViewController.h"
  
  @implementation Hack_DumpViewController
  
  @synthesize redButton;
  @synthesize greenButton;
  @synthesize yellowButton;
  @synthesize blueButton;
  @synthesize buttonMapping;
  
  - (IBAction) changeToYo:(id)sender {
      NSLog(@"changing numbers!");
      for (UIButton *b in buttonMapping) {
          [b setTitle:@"yo!"];
      }
      NSLog(@"changed to numbers!");
  }
  
  
  - (void)viewDidLoad {
  buttonMapping = [[NSArray alloc] initWithObjects:greenButton, redButton, yellowButton, blueButton, nil];    
  }
  </code></pre>