NSInvocation 是OC调用方法的方式之一
使用例子:
- (void)test {
SEL myMethod = @selector(myLog:parm:parm:);
NSMethodSignature * sig = [[self class] instanceMethodSignatureForSelector:myMethod];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig];
[invocation setTarget:self];
[invocation setSelector:myMethod];
int a = 1, b = 2, c = 3;
[invocation setArgument:&a atIndex:2];
[invocation setArgument:&b atIndex:3];
[invocation setArgument:&c atIndex:4];
[invocation invoke];
}
- (void)myLog:(int)a parm:(int)b parm:(int)c {
}
注意:这里的操作传递的都是地址。如果是OC对象,也是取地址
PS:本次只是做个记录,找个时间深入研究
比如,返回值,传入对象,如何实用等。