let className = "SKAlbumController"
//动态获取命名空间:
let nameSpace = Bundle.main.infoDictionary!["CFBundleExecutable"] as! String
//根据命名空间和传过来的控制器名字获取控制器的类
let controllerClass:AnyClass = NSClassFromString(nameSpace + "." + className)!
//告诉编译器真实的类型
let realClass = controllerClass as! UIViewController.Type
网友评论