Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
- (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
You can’t perform that action at this time.