使用 Invocation 来动态调用
2020-02-28 本文已影响0人
老猫_2017
NSInvocation 可以方便的调用
NSMethodSignature *signature = [target.class instanceMethodSignatureForSelector:sel];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setArgument:&userInfo atIndex:2];
[invocation setSelector:sel];
BOOL result = NO;
[invocation invokeWithTarget:self.global];
[invocation getReturnValue:&result];