Objective C 总结(十五):Logging
NSMutableArray *someObject = [NSMutableArray array]; NSLog(@"%s:%d someObject=%@", __func__, __LINE__, someObject); [someObject addObject:@"foo"]; NSLog(@"%s:%d someObject=%@", __func__, __LINE__, someObject);
Macro |
Format Specifier |
Description |
---|---|---|
__func__ |
%s |
Current function signature. |
__LINE__ |
%d |
Current line number in the source code file. |
__FILE__ |
%s |
Full path to the source code file. |
__PRETTY_FUNCTION__ |
%s |
Like __func__, but includes verbose type information in C++ code. |
Expression |
Format Specifier |
Description |
---|---|---|
NSStringFromSelector(_cmd) |
%@ |
Name of the current selector. |
NSStringFromClass([self class]) |
%@ |
Name of the current object's class. |
[[NSString stringWithUTF8String:__FILE__] lastPathComponent] |
%@ |
Name of the source code file. |
[NSThread callStackSymbols] |
%@ |
NSArray of the current stack trace as programmer-readable strings. For debugging only, do not present it to end users or use to do any logic in your program. |