title: instantiate ViewController and cast it to class from string in Swift
body: <p>I have array of strings </p>
  
  <pre><code>var arr = ["firstViewController", "secondViewController", ....]
  </code></pre>
  
  <p>For each of it's items I need to instantiate ViewController like </p>
  
  <pre><code>var myVC = self.storyboard?.instantiateViewController(withIdentifier: "firstViewController") as! firstViewController
  </code></pre>
  
  <p>If i want to instantiate View Controllers from loop I need to make class from string but this code </p>
  
  <pre><code>let namespace = Bundle.main.infoDictionary!["CFBundleExecutable"] as! String
  let cls: AnyClass = NSClassFromString("\(namespace).\(className)")!
  </code></pre>
  
  <p>Is not working </p>