Selecting an object based on a string name

Is there a way in objective-c / Cocoa to place an object when the class name is not known before execution. It seems that I remembered something about this some time ago, but now I can not find anything.

Sort of:

[[@"MyClass" alloc] init]; 

I seem to recall a function that returns some type of class identifier based on a string that can then be used to highlight an object.

+4
source share
1 answer
 id object = [[NSClassFromString(@"MyClass") alloc] init]; 
+9
source

Source: https://habr.com/ru/post/1306278/


All Articles