The C Preprocessor provides some standard macros that can provide information about the current file, row number, or function. In addition, Objective-C has the _ cmd implicit parameter, which can provide the selector of the current function and convert the selector and class to a string. You can provide the context information in the NSLog statement during debugging or error handling. The following is an example of printing the current method and row number. NSMutableArray * someObject = [NSMutableArray array]; NSLog (@ "% s: % d someObject = % @", _ func __, _ LINE __, someObject ); [someObject addObject: @ "foo"]; NSLog (@ "% s: % d someObject = % @", _ func __, _ LINE __, someObject ); the following are very common macros and expressions that are useful in log statements. Preprocessing macros used for log output in C/C ++/Objective-C. macro Format Specifier Description _ func _ % s before the current function _ LINE _ % d LINE number in the source code FILE _ % s full path of the source code FILE _ PRETTY_FUNCTION _ _ % s and _ func _ are similar, however, the C ++ Code contains more information. expression Format Specifier DescriptionNSStringFromSelector (_ cmd) % @ NSStringFromClass ([self class]) for log output in Objective-C % @ name of the current object class [[NSString stringwithuf8string :__ FILE _] lastPathComponent] % @ name of the source code FILE [NSThread CallStackSymbols] % @ the scale string array of the current stack information. It is only used for debugging and does not need to be presented to end users or used as any logic in the code.