通过字符串添加对应对象
2016-03-18 00:00
274 查看
摘要: Class test1 = NSClassFromString(NSString *str);
id test = [[test1 alloc]init];
Class test1 = NSClassFromString(NSString *str);
id test = [[test1 alloc]init];
也可以:
NSArray *array = [ [ViewController1 class],[ViewController2 class]];
id test = [[class alloc]init];
由于此方法是运行时编译所以必须,在线程、方法中运行
id test = [[test1 alloc]init];
Class test1 = NSClassFromString(NSString *str);
id test = [[test1 alloc]init];
也可以:
NSArray *array = [ [ViewController1 class],[ViewController2 class]];
id test = [[class alloc]init];
由于此方法是运行时编译所以必须,在线程、方法中运行
相关文章推荐
- Android Native 绘图方法
- C#中struct和class的区别详解
- VBS ArrayList Class vbs中的数组类
- 大家看了就明白了css样式中类class与标识id选择符的区别小结
- 深入了解PHP类Class的概念
- jquery 表单验证之通过 class验证表单不为空
- setAttribute 与 class冲突解决
- JavaScript中的类(Class)详细介绍
- javascript面向对象包装类Class封装类库剖析
- 详解js中class的多种函数封装方法
- jQuery使用hide方法隐藏指定元素class样式用法实例
- jQuery给多个不同元素添加class样式的方法
- jQuery点击改变class并toggle及toggleClass()方法定义用法
- jquery采用oop模式class类的使用示例
- JavaScript更改class和id的方法
- 一篇入门的php Class 文章
- 深入C++中struct与class的区别分析
- js中设置元素class的三种方法小结
- JavaScript操作class和style样式代码详解
- c++中typename和class的区别介绍