それは触発されています:
Objective-Cでさまざまなタイプのデータ型を印刷するにはどうすればよいですか?
ただし、NSLogタイプの関数が必要です。
これは私の現在のマクロです
#define ELog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#define DLog( s, ... ) ;;
//#define CLog( s, ... ) ;
#define CLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#define CM( s, ... );// NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#define PO1(x) ELog(@#x ": %@", x)
#define PD(x) ELog(@#x ": %f", x)
#define PI(x) ELog(@#x ": %d", x)
私はこのようなものが欲しいのですが、もしそうなら
PO(somevariable)、それがNSObjectであるか、doubleであるか、floatであるか、integerであるかに関係なく、必要なログを生成します。
どこかで見たことがあると思います。検索しても見つかりませんでした。