gpt4 book ai didi

objective-c - NSLog 和 DLog 的区别

转载 作者:太空狗 更新时间:2023-10-30 03:12:04 25 4
gpt4 key购买 nike

谁能告诉我 NSLogDLog 有什么区别?

我在查看这个项目代码时发现了这个 DLog:http://code.google.com/p/iphone-socks-proxy/

最佳答案

DLog 是一种常用的“Debug NSLog”替代品(只有谷歌)

这是一套完整的 Log #define 指令(包括 ULog,一个基于 UIAlertView 的日志功能)

// DLog will output like NSLog only when the DEBUG variable is set

#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif

// ALog will always output like NSLog

#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);

// ULog will show the UIAlertView only when the DEBUG variable is set

#ifdef DEBUG
# define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
# define ULog(...)
#endif

只需将它们放入您的预编译头 (.pch) 文件即可。

(来源:http://overbythere.co.uk/blog/2012/01/alternatives-nslog)

关于objective-c - NSLog 和 DLog 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9659763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com