Like C, Objective-C provides some standard macros that describe the number of lines of the current file, source code file, and function information. Objective-C also provides related class types. Can be applied to debugging and error handling logs.
Macros provided by the pre-processor in C/C ++/Objective-C Language
* _ Func __% s current function signature * _ LINE __% d Number of current lines in the source code file
* _ FILE _ % s full path of the current source code FILE
* _ PRETTY_FUNCTION _ % s image _ func __, but contains the invisible type information in the C ++ code.
Some log information used in Objective-C
* NSStringFromSelector (_ cmd) % @ current selector name limit * NSStringFromClass ([selfclass]) % @ current Object Name limit * [[NSString stringwithuf8string: ** FILE **] lastPathComponent] % @ source code FILE name
* [NSThreadcallStackSymbols] % @ The Readable string array of the current stack. It is only used during scheduling.
** Sample code :**
• # Import <foundation/Foundation. h>
•
• @ Interface TestObj: NSObject
•-(Void) fun :( NSString *) input;
• @ End
•
• @ Implementation TestObj
•-(Void) fun :( NSString *) input {
NSLog (@ "% s: % d: % s", _ func __, _ LINE __, _ FILE __,__ PRETTY_FUNCTION __);
NSLog (@ "% @", NSStringFromSelector (_ cmd ));
NSLog (@ "% @", NSStringFromClass ([self class]);
NSLog (@ "% @", [[NSString stringwithuf8string :__ FILE _] lastPathComponent]);
NSLog (@ "% @", [NSThread callStackSymbols]);
NSLog (@ "% @", input );}
@ End
Int main (int argc, const char * argv []) {
@ Autoreleasepool {
TestObj * to = [[TestObj alloc] init];
[To fun: @ "call"];
[To release];
}
Return 0;
}