title: How to instantiate a new view controller programmatically
body: <p>I have a ViewController with two UIButtons and UIlabels. </p>
  
  <p>In order to make similar ViewController of this, I would like to instantiate a new view controller programmatically
  like this.</p>
  
  <pre><code>let vc = storyboard.instantiateViewControllerWithIdentifier("Main")
  </code></pre>
  
  <p>Then navigate to the view controller like this:</p>
  
  <pre><code>navigationcontroller?.pushViewController(vc, animated: true)
  </code></pre>
  
  <p>I have set StoryBoard ID as <code>"Main"</code>, however I do not know where I can write these codes.</p>
  
  <pre><code>    class ViewController: UIViewController, AVAudioPlayerDelegate {
  
      let url1 = Bundle.main.bundleURL.appendingPathComponent("music1.mp3")
      let url2 = Bundle.main.bundleURL.appendingPathComponent("music2.mp3")
  
          @IBOutlet weak var label1: UILabel!
          @IBOutlet weak var label2: UILabel!
  
          @IBOutlet weak var yourButton1: customButton!
          @IBOutlet weak var yourButton2: customButton!
  
          override func viewDidLoad() {
              super.viewDidLoad()
  
              label1.text = "Hello1"
              label2.text = "Hello2"
          }
  
          override func didReceiveMemoryWarning() {
              super.didReceiveMemoryWarning()
          }
  
     func player(url: URL) {
          do {
              try player = AVAudioPlayer(contentsOf:url)
              player.play()
  
          } catch {
              print(error)
          }
      }
  
     @IBAction func pushButton1(sender: UIButton) {
         player(url: url1)
      }
  
      @IBAction func pushButton2(sender: UIButton) {
         player(url: url2)
      }
          }
  </code></pre>
  
  <p>tableView</p>
  
  <pre><code>   class SecondTableViewController: UITableViewController {
  
      var names = [String]()
      var identities = [String]()
  
      override func viewDidLoad() {
  
          names = ["name1","name2","name3","name4"]
          identities = ["Main","Main2","Main3","Main4"]
  
      }
  
      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return names.count
      }
  
  
      override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
          let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
  
          let label1 = cell?.viewWithTag(1) as! UILabel
          label1.text = "\(names[indexPath.row])"
  
          return cell!
      }
  
  
      override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          let vcName = identities[indexPath.row]
          let ViewController = storyboard?.instantiateViewController(withIdentifier: vcName)
          self.navigationController?.pushViewController(ViewController!, animated: true)
      }
  
  
  }
  </code></pre>