通过文件名利用NSClassFromString, 取到Class类别,通过setValue:forKey:传递值

来源:互联网 发布:c语言null 编辑:程序博客网 时间:2024/05/18 02:24


        // 1. arg.className为文件名字

        Class clazz =NSClassFromString(arg.className);

        //2.destVC 为一个实体类

        UIViewController *destVC = [clazznew];


        //3.propertyName为clazz类的一个属性名字(例如.h中  @property(strong,nonatomic)NSString *propertyName;   )   其中propertyValue为传递的参数

        [destVCsetValue:propertyValueforKey:propertyName];


0 0
原创粉丝点击