title: How to add an NSView to NSWindow in a Cocoa app?
body: <p>Since the template of an OS X app in Xcode seems to be similar to an empty app template, the following is used to add a view and a button (trying not to use Interface builder for now):</p>
  
  <pre><code>- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  {       
      NSView *view = [[NSView alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)];
  
      view.layer.backgroundColor = [[NSColor yellowColor] CGColor];
  
      [self.window.contentView addSubview:view];
  
      NSRect frame = NSMakeRect(10, 40, 90, 40);
      NSButton* pushButton = [[NSButton alloc] initWithFrame: frame]; 
      pushButton.bezelStyle = NSRoundedBezelStyle;
  
      [self.window.contentView addSubview:pushButton];
  
      NSLog(@"subviews are %@", [self.window.contentView subviews]);   
  }
  </code></pre>
  
  <p>Similar code on iOS should have produced a yellow box and a button, but the code above only produce a button, but the view won't show.  Is there something wrong with the code above, and how to make it show the view with a yellow background?</p>