Created
July 2, 2019 09:07
-
-
Save qy1010/f0f64b64e3b0891ec312983a0b2cd3f6 to your computer and use it in GitHub Desktop.
NSInvocation create & invoke
This file contains 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
// 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