美文网首页
android和iOS 通过className获取Class

android和iOS 通过className获取Class

作者: fordG | 来源:发表于2018-11-19 15:07 被阅读0次

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);

相关文章

网友评论

      本文标题:android和iOS 通过className获取Class

      本文链接:https://www.haomeiwen.com/subject/umfafqtx.html