title: Interface-Builder: "combine" NSView-class with .xib
body: <p>I'd like to set up a custom NSView in Interface-Builder, but I don't get it to work for OSX.</p>
  
  <p>In my ViewController's .xib, I added a custom view and set the Class to MyCustomView. I created MyCustomView.h, MyCustomView.m and MyCustomView.xib.</p>
  
  <p>In MyCustomView.xib, I set the Class to MyCustomView as well. In MyCustomView.m, <code>- (void)awakeFromNib</code> is called, but <code>- (id)initWithCoder:(NSCoder *)aDecoder</code> and <code>- (id) awakeAfterUsingCoder:(NSCoder*)aDecoder</code> aren't.</p>
  
  <p>What I'd like to achieve is that in my ViewController, the view I added is "filled" with the view I set up in MyCustomView.xib. What's the best way to do that?</p>
  
  <p><strong>EDIT: I don't think I was clear enough...</strong></p>
  
  <p>I've got my ViewController containing a Custom View called MyCustomView.</p>
  
  <p><img src="https://i.stack.imgur.com/2jnGh.png" alt="enter image description here"></p>
  
  <p>This view should be of type MyCustomView, where</p>
  
  <p>MyCustomView.h
  MyCustomView.m
  MyCustomView.xib</p>
  
  <p>exists. I already set the File's Owner of MyCustomView.xib to MyCustomView and I already set the CustomView in my ViewController to MyCustomView - but it doesn't work.</p>
  
  <p>If I do it with</p>
  
  <pre><code>- (void)awakeFromNib {
      NSString* nibName = NSStringFromClass([self class]);
      NSArray* topLevelObjects;
      [[NSBundle mainBundle] loadNibNamed:nibName
                                owner:nil
                      topLevelObjects:&amp;topLevelObjects];
  
      NSView* view = topLevelObjects[0];
      [view setFrame:[self bounds]];
      [self addSubview:view];
  }
  </code></pre>
  
  <p>I only get a view of type NSView, not MyCustomView... Is there no easy way to tell the ViewController.xib that it's a MyCustomView?</p>
  
  <p><strong>EDIT 2: I uploaded a simple project</strong></p>
  
  <p>At <a href="https://dl.dropboxusercontent.com/u/119600/Testproject.zip" rel="noreferrer">https://dl.dropboxusercontent.com/u/119600/Testproject.zip</a> you find a simple project with the MyCustomView (not in a ViewController but in the window.xib) - but it doesn't show the button which is in MyCustomView.xib. I'd like to achieve exactly that - what's the simplest, best way?</p>