title: Objective-C: How to switch the NSView by button click
body: <p>I have different xib files with NSViewController attached to them. (Screenshot below)</p>
  
  <p><img src="https://i.stack.imgur.com/ZZaJm.png" alt="enter image description here"></p>
  
  <p>One of xib file called StartMenuViewController which has a button. I want to click that button and change the view to DetectingUSBViewController.(Screenshot below)
  The IBAction of that button is in StartMenuViewController.m file.</p>
  
  <p><img src="https://i.stack.imgur.com/qIISU.png" alt="enter image description here"></p>
  
  <p>And I use AppController.m to control my main xib view.(NSWindow + NSView) (Screenshot below)
  <img src="https://i.stack.imgur.com/Zwv9m.png" alt="enter image description here"></p>
  
  <p>When the application runs, I try to initialize the StartMenuViewController fist by doing the following thing in my AppController.m file.</p>
  
  <pre><code>-(void)awakeFromNib{   
      [self initialize];
  }
  
  -(void) initialize
  {
      @autoreleasepool {
          //mainViewController is a NSViewController and _mainView is a NSView which connect with Custom View in main xib
          self.mainViewController = [[[StartMenuViewController alloc]initWithNibName:StartMenuView bundle:nil]autorelease];
          [_mainView addSubview:[_mainViewController view]];
      }
  }
  </code></pre>
  
  <p>It works fine and it will show the StartMenuViewController.xib on the window at first, but I do not know how to change the view after clicking the button(FIND USB DRIVE). I want the current view changes to DetectingUSBViewController.xib.</p>