Xcode debug log can print the method name using %B
and the hit count using %H
. How can I print the interface / object name using similar notation ? Preferably without the use of NSLog / debugger command.

- 442
- 5
- 14
-
1have you tried NSLog(@"%@", [yourObject class]); ? – Miknash Apr 21 '15 at 12:12
5 Answers
The closest you can get is
NSLog("My file is %@", [NSString stringWithUTF8String:__FILE__]);
__PRETTY_FUNCTION__
contains the class name and method, which may suit you better than FILE.

- 23,007
- 8
- 61
- 83
-
-
OK Well if not NSLog, how do you want it? You could use the same parameters and call printf instead, for example. – Graham Perks Apr 21 '15 at 15:29
-
Like the one which doesn't need a debugger action but a only a log action. See [my answer](http://stackoverflow.com/a/29774554/2182047). Do you have any similar answer ? – lalthomas Apr 21 '15 at 19:45
Every Objective-C object can be printed with %@
. NSLog(@"%@", someObject)
will print object's description. You can override description
method for your classes to provide more detailed info. Look at this note too: Improved logging in Objective-C

- 7,199
- 2
- 25
- 32
In the breakpoint's debugger command action, you can put:
expr printf ("[%s %s]\n", (char *)object_getClassName(self), _cmd)
This will output, e.g. [SomeClass someMethod:]

- 23,007
- 8
- 61
- 83
You can print anything using NSLog();
Say, for example, you have an
NSString *myString = @"qdfsqsdfqsdf";
This is an important string you would like to log, you'll just type :
NSLog(@"My important string : %@", myString);
If that is what you're asking, I'm surprised you dont' know that if you already know about %B
& %H
. Am I answering your question or do you need a bit more?

- 5,802
- 5
- 36
- 78