The script appears where I have an object that stores an external @selector for later use. By design, I would like to be able to add two kinds of selectors. Simple, without parameters, for example [object add:@selector(doSomething)] , and more complex, with one parameter, for example [object add:@selector(doSomething:)] (colon mind). Let's say the selector is stored in the SEL mySelector variable SEL mySelector .
On execution, I need to choose between [anotherObject performSelector:mySelector] or [anotherObject performSelector:mySelector withObject:userInfo]] .
The way I implemented this solution is to provide a BOOL flag that preserves excessively whether the performance should work with or without an additional parameter. However, although I cannot find this in the documents, I get the feeling that I can also set the selector something like -(BOOL)needsParameter . I know, for example, that UIGestureRecognizer addTarget: action: somehow makes this difference automatically.
Can someone point me in the right direction?
source share