Swift根据类名创建对象

guard let test: AnyObject.Type = NSClassFromString("ViewController") else {
  return
}
guard let customClass = test as? ViewController.Type else {
  return
}
let vc = customClass.init()

推荐阅读更多精彩内容