class IndexViewController: UIViewController{} let className = "IndexViewController" let bundlePath = NSBundle.mainBundle().bundlePath let bundleFullName = bundlePath.componentsSeparatedByString("/").last let bundleName = bundleFullName?.componentsSeparatedByString(".").first let clazz = NSClassFromString(bundleName! + "." + className)! as! UIViewController.Type let object = clazz.init() // let object1 = Index() 普通方法
时间: 2024-12-07 02:58:34