A-Hing
7/2/2019 - 9:07 AM

NSInvocation

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];