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);

}

posted @ 2013-09-26 12:02  天下.无贼  阅读(178)  评论(0)    收藏  举报