I've got a call like this [Class method] and a warning saying that Class may not respond to "method" message.
The "method" message does not indeed exist but my code use unknown message catching (using forwardingTargetForSelector) so it will run fine and it is build to run that way. How can I hide this annoying warning ?
If you intend to send a possibly-unimplemented message to an object, and you know that you're going to catch failures, you should use the invocation:
id myClone = [anObject performSelector:@selector(copy)];
That declares your intent more directly that you are calling a method that may not exist, and you're cool with that. This is a more clear way to do it than to suppress the warning or fake out the method.
You could define a category that declares that method. Having the definition in scope at the time of compilation would avoid the warning. Something like
@interface MyClass (ShutUpTheCompilerMethods)
- (void)method;
@end
...
[MyClass method] //no warning here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With