vod*_*ang 15 iphone debugging objective-c
继续上一个问题:Obj-C中的日志方法名称.我只是想知道是否有办法打印变量名称.例如:
NSString *name = "vodkhang";
NCLog(@"%@", name);
Run Code Online (Sandbox Code Playgroud)
我希望输出应该是:
name: vodkhang
Run Code Online (Sandbox Code Playgroud)
只是总结一下上一篇文章,目前我可以在打电话时打印出班级名称,方法名称和行号
NCLog(@"Hello World");
<ApplicationDelegate:applicationDidFinishLaunching:10>Hello world
Run Code Online (Sandbox Code Playgroud)
同
#define NCLog(s, ...) NSLog(@"<%@:%d> %@", __FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__])
Run Code Online (Sandbox Code Playgroud)
gna*_*her 36
#define logIntVariable(x) NSLog( @"Value of %s = %d",#x, x)
- (void) myRoutine {
int intValue = 5;
logIntVariable(intValue);
}
Run Code Online (Sandbox Code Playgroud)