Clear iOS debugging information

Source: Internet
Author: User

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;

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.