我有一个方法可以告诉我该 indexPath 处的对象应该是什么类(基于带字符串的数组);
但是这会引发错误
"Use of undeclared identifier 'instanceCell'
Class companyCellClass = [HomePageFlagIndexing tableCellClassForIndexPath:indexPath];
companyCellClass *instanceCell = [tableView dequeueReusableCellWithIdentifier:[HomePageFlagIndexing getIdentifierForIndexPath:indexPath]forIndexPath:indexPath];
有没有办法像这样以编程方式设置类?
最佳答案
companyCellClass 是一个 Class 对象而不是一个 Type,用 UITableViewCell 改变它。
如果您随后想要执行在该类 header 中声明的任何操作,首先您必须手动将其向下转换为您的类并执行,或者发送 performSelector。
关于ios - 通过首先从方法中获取类来设置类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35698442/