Skip to content

Instantly share code, notes, and snippets.

@qy1010
Created July 2, 2019 09:07
Show Gist options
  • Save qy1010/f0f64b64e3b0891ec312983a0b2cd3f6 to your computer and use it in GitHub Desktop.
Save qy1010/f0f64b64e3b0891ec312983a0b2cd3f6 to your computer and use it in GitHub Desktop.
NSInvocation create & invoke
// create
- (NSInvocation*)createInvocationWithSelector:(SEL)selector {
NSMethodSignature *signature = [self methodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
invocation.target = self;
invocation.selector = selector;
return invocation;
}
//invoke
NSInvocation *invocation = self.eventStrategy[eventName]; // dict包装多个invocation
[invocation setArgument:&userInfo atIndex:2]; // 参数
[invocation invoke];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment