ios 不定长的多个参数的方法实现
//[ViewController writeWithFormat:@"1", @"2", @"3", nil];
+ (void)__methodName__:(NSObject*)string, ... NS_REQUIRES_NIL_TERMINATION // 结尾请带上一个nil
{
va_list args;
va_start(args, string);
if (string) {
NSLog(@"Do something with First: %@", string);
NSObject *other;
while ((other = va_arg(args, NSObject*))) {
NSLog(@"Do something with other: %@", other);
}
}
va_end(args);
}

浙公网安备 33010602011771号