How to display method name and class name in gdb

Hello everyone. I have been working on a new application from the very beginning. Now I use the nslog function call to output the output to gdb.but from some samples that provide me with a gdb mapping with the name of the class and method. some screenshot for this. Anyone can help me accept the method name and display name when using nslog ().

getting class name and method name with the log

Please provide me some information. Thanks in advance.

+4
source share
3 answers
NSLog(@"the method is %s", __func__); 

__ func__ is a built-in macro that extends to the current function or class name + (this is a standard C string, which means the format is %s instead of %@ ).

+10
source

I am using the following:

 NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd)); 

This will dynamically generate the name and class name similar to __func__ . If you use Xcode 3.x, then I made a Command-Option-L map for the following script user, which inserts a standard registration call, for example above:

enter image description here

+2
source

it will easily print out any method in which it will be placed ...

 NSLog(@"%s", __PRETTY_FUNCTION__); 
+1
source

Source: https://habr.com/ru/post/1344762/


All Articles