I have an object which is forwarding receiving messages. It does not implement forwarding them to other objects using forwardInvocation
. However, methodSignatureForSelector
will not always return a valid method signature at certain times because of the way the program is organized. How can I swallow the exception generated from the missing method signature? Overriding doesNotRecognizeSelector
does not work. Thanks.
Asked
Active
Viewed 563 times
2
1 Answers
5
You must generate some signature (even if a dummy one, e.g. v@:
, a signature of a method that returns void
and takes no arguments) and then remember to do nothing when it gets to forwardInvocation:
.

newacct
- 119,665
- 29
- 163
- 224
-
Could you post some example code for this... trying hard to do the same thing. – unom Mar 31 '14 at 21:53
-
2@unmircea: Basically, in your `methodSignatureForSelector:` method, if you decide to swallow the call for a selector, but don't have the signature, return `[NSMethodSignature signatureWithObjCTypes:"v@:"]`. Then, in your `forwardInvocation:` method, check the same condition on the selector for swallowing that you used in `methodSignatureForSelector:`, and if it is met, simply return and don't process further. – newacct Apr 01 '14 at 04:02