How to dynamically load class in Objective-C?

懵懂的女人 提交于 2019-12-19 03:14:47

问题


how to dynamically load a class in Objective-C? As per my need, class name will be in a text file, which i need to read it, and then load the class dynamically ...

This code is loading a class in Java... I want the same functionality to be done in Objective-C...

public class MainClass {

  public static void main(String[] args){

    ClassLoader classLoader = MainClass.class.getClassLoader();

    try {
        Class aClass = classLoader.loadClass("com.jenkov.MyClass");
        System.out.println("aClass.getName() = " + aClass.getName());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

}

which function in Objective-C is used instead of loadClass() in Java?


回答1:


You can start reading the Bundle Programming Guide, especially the Loading Objective-C Classes section. You will find all the information regarding discovery and dynamic code loading (both functions and classes).



来源:https://stackoverflow.com/questions/2198840/how-to-dynamically-load-class-in-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!