title: Swift - Segmented control - Switch multiple views
body: <p>Until now I still can't figure how to switch multiple views in one view controller. My storyboard is like this one.</p>
  
  <p><img src="https://i.stack.imgur.com/26E63.png" alt="enter image description here"></p>
  
  <p>Right now I want to embed two views inside my view controller.</p>
  
  <p><img src="https://i.stack.imgur.com/V7sIs.png" alt="enter image description here"></p>
  
  <p>My code for segmented control to switch two views in one view controller so far.</p>
  
  <pre><code>import UIKit
  
  class PopularHistoryViewController: UIViewController {
  
      @IBOutlet weak var segmentedControl: UISegmentedControl!
  
      @IBAction func indexChanged(sender: UISegmentedControl) {
          switch segmentedControl.selectedSegmentIndex
          {
          case 0:
              NSLog("Popular selected")
              //show popular view
          case 1:
              NSLog("History selected")
              //show history view
          default:
              break; 
          }
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
      }
  
  
  }
  </code></pre>
  
  <p>Another thing, If I put two views inside my controller, what is best practice to differentiate it?</p>