In another question ( how to instantiate an object of class from string in Objective-C? ), this was suggested:
id myclass = [[NSClassFromString(@"MyClass") alloc] init];
[myclass FunctioninClass];
However, [myClass FunctioninClass] yields an error because the compiler has no idea if FunctioninClass exists.
I do know the classes that can be there are all descendants of one parent. And that parent has the prototype of the method I want to call, except I want to call the overridden descendant method. Does that suggest a solution?
After @user523234’s comment, I decided to improve my answer and correct it. His answer, however, is in my opinion not good enough and will crash your code in case the selector is not available.
So here is the solution:
Using the – respondsToSelector: will make sure you check wether the sector exists in the class. However, you will need to use the preformSelector everytime. I am unsure if you can dynamically type-cast an identifier.