How to dynamically load a class in Objective-C?

How to dynamically load a class in Objective-C? According to my need, the class name will be in a text file that I need to read, and then dynamically load the class ...

This code loads the class in Java ... I want the same functions to be executed 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?

+5
source share
1 answer

You can start reading the Bundle Programming Guide , especially Downloading Objective-C Classes . You will find all the information about detecting and dynamically loading code (both functions and classes).

+8
source

All Articles