Reputation: 452
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.
Upvotes: 0
Views: 570
Reputation: 23400
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:]
Upvotes: 0
Reputation: 452
I just found that @[self class]@
log message will do the trick. I am not sure its validity on every occasion. I am using @[self class]@ %B %H
for my purpose. I also found this question and answer but it was not just working on Xcode 6.2.
Upvotes: 1
Reputation: 23400
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.
Upvotes: 1
Reputation: 7260
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
Upvotes: 0
Reputation: 6038
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?
Upvotes: -1