android获取class
//通过string获取Class
String itemString = dataSource[position];
Class cla = null;
try {
cla = Class.forName("com.example.fordgao.helloworld."+itemString);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
//通过Class对象获取类名
this.getLocalClassName()
iOS获取class
//通过string获取Class
NSClassFromString(@"ViewController");
//通过Class对象获取类名
NSStringFromClass(self);
网友评论