If you're looking for a way to do this without writing a lot of code, you're out of luck. As a rule, Obj-C does not have much "syntactic sugar", and this is one such situation.
In most cases, you just do exactly what you are trying to avoid. It is easy and works.
But when it’s not very good, the Obj-C runtime has the “Forward Messages” feature.
Basically, if your object receives a message (method call) that it knows nothing about, the default behavior is to throw an exception. But your object may decide to do something else with it, and there are millions of places where the Obj-C Framework classes do this.
In most cases, you forward the message to another object, but you can do whatever you want:
- (void)forwardInvocation:(NSInvocation *)anInvocation { if () { return; }
The official documentation with many details can be found here: https://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtForwarding.html
source share