Reflection is not recommended in swift, so what is the solution to getting a class by class name?

SWIFT is not recommended to operate with reflection, but how do I deal with a list of string? when I click on a cell in the list, I get the corresponding class through this string and add the UIVIEW of the corresponding class?

Aug.30,2021

I don't know what your specific needs are.
if it's annoying for TableView to register or get Cell.


extension UITableView {
    func registerNib(withCellClass clz: Swift.AnyClass, bundle: Bundle? = nil) {
        let className = String(describing: clz)
        let nib = UINib(nibName: className, bundle: bundle)
        self.register(nib, forCellReuseIdentifier: className)
    }

    func dequeueReusableCell<T: UITableViewCell>(type: T.Type, for indexPath: IndexPath) -> T? {
        let className = String(describing: T.classForCoder())
        guard let cell = self.dequeueReusableCell(withIdentifier: className, for: indexPath) as? T else {
            fatalError("cell of [\(className)] is not register as \(className)")
        }
        return cell
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7ae281-276cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7ae281-276cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?