title: Naming Controls using XCode Storyboarding
body: <p>I am learning the basics of controls and event handling as I transition from .NET to Objective-C.</p>
  
  <p>I have created a Single View project in XCode 4.2, using ARC and Storyboarding.  On the Storyboard, the ViewController has a single UIImageView and a UIButton.  The UIImageView is assigned the name 'imgLock' in the Identity Inspector's 'label' entry.  The same technique is used to name the button 'btnToggle'.</p>
  
  <h2>ViewController.h</h2>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController {
    IBOutlet UIButton *btnToggle;
    IBOutlet UIImageView *imgLock;
  }
  
  - (IBAction) toggleImage;
  
  @property (readonly, strong) UIButton *btnToggle;
  @property (readwrite, strong) UIImageView *imgLock;
  @end
  </code></pre>
  
  <h2>ViewController.m</h2>
  
  <pre><code>#import "ViewController.h"
  
  @implementation ViewController
  @synthesize btnToggle, imgLock;
  
  BOOL imgState;
  
  - (void) toggleImage {
      UIImage *img = [UIImage imageNamed: imgState ? @"Unlocked64" : @"Locked64"];
      imgState = !imgState;
      [imgLock setImage: img];
  }
  </code></pre>
  
  <p>On the Storyboard, I Ctrl-dragged the blue line from the button to the image, and selected <code>toggleImage</code> from the resulting context menu.</p>
  
  <p>When I put a breakpoint in <code>toggleImage</code> and Build/Run the project, I see that everything is as it should be, except that <code>imgLock</code> is 0x0.  From my Windows days, I guess I was expecting the controls to be instantiated because they were "placed on the form" as it were.</p>
  
  <p>The log is free of comments, except a warning when killing the process: <strong>warning: error on line 2184 of "/SourceCache/gdb/gdb-1708/src/gdb/macosx/macosx-nat-inferior.c" in function "void macosx_kill_inferior_safe()"</strong></p>