Created
May 10, 2018 16:01
-
-
Save soxjke/0663911676daae69064dd6a5b7e5348b to your computer and use it in GitHub Desktop.
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
| - (NSMethodSignature *)methodSignatureForSelector:(SEL)sel { | |
| NSMethodSignature * __block signature = nil; | |
| [self.implementations enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
| signature = [obj methodSignatureForSelector:sel]; | |
| *stop = (nil != signature); | |
| }]; | |
| return signature; | |
| } | |
| - (BOOL)respondsToSelector:(SEL)aSelector { | |
| BOOL __block result = NO; | |
| [self.implementations enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
| result = [obj respondsToSelector:aSelector]; | |
| *stop = result; | |
| }]; | |
| return result; | |
| } | |
| - (void)forwardInvocation:(NSInvocation *)invocation { | |
| BOOL __block result = NO; | |
| @weakify(invocation) | |
| [self.implementations enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
| @strongify(invocation); | |
| result = [obj respondsToSelector:invocation.selector]; | |
| if (result) { | |
| [invocation invokeWithTarget:obj]; | |
| [invocation retainArguments]; | |
| } | |
| *stop = result; | |
| }]; | |
| if (!result) { | |
| [super forwardInvocation:invocation]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment