Objective-C How to save the pointer to a static method in a variable?

0

I would like to save in a variable the address of a static method and then call it when it interests as if it were a function pointer in C.

How would it be implemented in Objective C? Would it work the same for non-static methods?

    
asked by Popularfan 21.11.2016 в 22:17
source

1 answer

2

You only have to create a selector pointing to the static method of the class

Class class = NSClassFromString(@"NombreDeLaClase");
SEL selector = NSSelectorFromString(@"nombreDelMetodo");

Then to call it you just have to perform a selector

[class performSelector:selector];
    
answered by 24.11.2016 / 20:03
source