// 方法一、
// 把参数放进一个数组/字典,直接把数组/字典当成一个参数传过去,具体方法实现的地方再解析这个数组/字典
NSArray* array =
[NSArray arrayWithObjects: @"first", @"second", nil];
[selfperformSelector:@selector(fooFirstInput:) withObject: array afterDelay:15.0];
// 方法二、
// 使用NSInvocation
SEL aSelector = NSSelectorFromString(@"doSoming:argument2:");
NSIntegerargument1 =10;
NSString*argument2 =@"argument2";
if([selfrespondsToSelector:aSelector]) {
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[selfmethodSignatureForSelector:aSelector]];
[inv setSelector:aSelector];
[inv setTarget:self];
[inv setArgument:&(argument1) atIndex:2];
[inv setArgument:&(argument2) atIndex:3];
[inv performSelector:@selector(invoke) withObject:nilafterDelay:15.0];
}
网友评论