Created
July 2, 2015 10:54
-
-
Save itsthejb/795a75cd14db2f33fccf to your computer and use it in GitHub Desktop.
Child property forwarding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Forward any unimplemented methods to a particular object property | |
| */ | |
| #define FORWARD_TO_PROPERTY(PROPERTY) \ | |
| - (void)forwardInvocation:(NSInvocation *)anInvocation { \ | |
| if ([super respondsToSelector:anInvocation.selector]) { \ | |
| [super forwardInvocation:anInvocation]; \ | |
| } else { \ | |
| [anInvocation invokeWithTarget:PROPERTY]; \ | |
| } \ | |
| } \ | |
| - (BOOL)respondsToSelector:(SEL)aSelector { \ | |
| if (![super respondsToSelector:aSelector]) { \ | |
| return [PROPERTY respondsToSelector:aSelector]; \ | |
| } \ | |
| return YES; \ | |
| } \ | |
| - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { \ | |
| NSMethodSignature *signature = [super methodSignatureForSelector:aSelector]; \ | |
| if (!signature) { \ | |
| signature = [(id) PROPERTY methodSignatureForSelector:aSelector]; \ | |
| } \ | |
| return signature; \ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment