在.h头文件声明函数:
-(void)Test:(id)param1 second:(id)param2, ...;
在.m文件中实现函数:
-(void)Test:(id)param1 second:(id)param2, ...{
NSLog(@"param1 class type :%@", [param1 class]);
NSLog(@"param2 class type :%@", [param2 class]);
id param3;
va_list argList;
va_start(argList,param2);
while ((param3 = va_arg(argList,id))) {
NSLog(@"%@",[param3 class]);
}
va_end(argList);
}
//在其它地方调用上面的函数:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSNumber *number = [NSNumber numberWithInt:1];
//测试带多个不确定参数的函数
MyTest *mp=[[MyTest alloc] init];
[mp Test:@"param1" second:@"param2", btn, webView, number, nil];