title: Programmatically Creating Controls in Cocoa
body: <p>According to <em>Cocoa Programming for Mac OS X, 3rd Edition</em>, on page 245 (chapter 17), you will usually create views in Interface Builder. However, it is possible to create them in code, a la:</p>
  
  <pre><code>NSView *superview = [window contentView]; 
  NSRect frame = NSMakeRect(10, 10, 200, 100); 
  NSButton *button = [[NSButton alloc] initWithFrame:frame]; 
  [button setTitle:@"Click me!"]; 
  [superview addSubview:button]; 
  [button release]; 
  </code></pre>
  
  <p>That’s all well and good, but how would I wire up said control’s outlets to actions in code? (In .NET, this is an easy thing; add a delegate ... I’m hoping it’s similarly easy in Cocoa/Obj-C.)</p>