title: Cocoa - How do I initialize a view programmatically ?
body: <p>I have a problem understanding how to initialize a view without hooking it up in my nib-file. 
  So what I want to do is, instead of dragging in a view and assigning it a dedicated class, I want to programmatically add it to my window in my app delegate. </p>
  
  <p>I don't really know how wrong this is, but I tried something like this in my AppDelegate: </p>
  
  <pre><code>- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  {
      DView *dV = [[DView alloc]initWithFrame:NSMakeRect(0, 0, 1000, 600)];
      [self.window addSubview:dV];
  }
  </code></pre>
  
  <p>I figured that the window is an NSView as well, so why not just add it to it ? But this crashes and ends in an infinite loop. I hope you can help me. Thanks. </p>