Swift 字符串转类型

    技术2022-07-11  124

    let projectName = Bundle.main.infoDictionary!["CFBundleExecutable"] as? String let className = projectName! + "." + controllerName let vc = NSClassFromString(className) as! UIViewController.Type let viewController = vc.init() self.navigationController?.pushViewController(viewController, animated: true)

     

    Processed: 0.014, SQL: 9