http://my.oschina.net/u/2340880/blog/398552
- (void)viewDidLoad { [super viewDidLoad]; SEL myMethod = @selector(myLog:parm:parm:); NSMethodSignature * sig = [[self class] instanceMethodSignatureForSelector:myMethod]; NSInvocation * invocatin = [NSInvocation invocationWithMethodSignature:sig]; [invocatin setTarget:self]; [invocatin setSelector:myMethod2]; int a=1; int b=2; int c=3; [invocatin setArgument:&a atIndex:2]; [invocatin setArgument:&b atIndex:3]; [invocatin setArgument:&c atIndex:4]; [invocatin invoke];}-(void)myLog:(int)a parm:(int)b parm:(int)c{ NSLog(@"MyLog%d:%d:%d",a,b,c);}
本文介绍了一种在Objective-C中使用NSInvocation进行动态方法调用的方法。通过实例展示了如何设置目标、选择器及参数,并调用指定方法。这对于理解Objective-C运行时机制及其应用非常有用。
208

被折叠的 条评论
为什么被折叠?



