Skip to content

Instantly share code, notes, and snippets.

@KatagiriSo
Created December 26, 2011 06:53
Show Gist options
  • Save KatagiriSo/1520647 to your computer and use it in GitHub Desktop.
Save KatagiriSo/1520647 to your computer and use it in GitHub Desktop.
variable argument method
#import <stdarg.h>
void myLog(NSString *message,...);
@interface ViewController : UIViewController
- (void)myLog:(NSString *)message,... NS_REQUIRES_NIL_TERMINATION;
@end
void myLog(NSString *message,...) {
va_list list;
va_start(list,message);
NSObject *obj = va_arg(list, NSObject*);
while (obj) {
NSLog(@"%@",obj);
obj = va_arg(list, id);
}
//NSLogv(message, list);
va_end(list);
}
@implementation ViewController
- (void)myLog:(NSString *)message, ...
{
va_list list;
va_start(list,message);
NSObject *obj = va_arg(list, NSObject*);
while (obj) {
NSLog(@"%@",obj);
obj = va_arg(list, id);
}
//NSLogv(message, list);
va_end(list);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment