Created
December 26, 2011 06:53
-
-
Save KatagiriSo/1520647 to your computer and use it in GitHub Desktop.
variable argument method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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