How can I run the method programmatically as described by the selector?

Example: I have such a selector that I pass to another method as a parameter:

SEL mySelector = @selector(doSomething:);

I would like to call this method doSomething inside this method.

Background: I have a method that performs some basic animation actions. It uses already didStopSelector, which calls a special memory management method when everything is done. But then, I want to be able to call a simple method that does not accept any special parameters, in order to do some things later. But this method is not responsible for calling the memory management method, so I need, for example, to run the selector, which I store in ivar.

+3
source share
2 answers
[receivingObject performSelector:mySelector withObject:someParam];

withObject, . . docs NSObject.

+8

NSObject performSelector:

- (id)performSelector:(SEL)aSelector withObject:(id)object;
- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
+2

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


All Articles