When setting a breakpoint in Xcode there is the %B
shortcut. Placed into the "Log message" it will print the breakpoint name to the console. The breakpoint name
will be the method name.
So creating a breakpoint in - (void)viewDidLoad
will print
-viewDidLoad
When the breakpoint stops all is clear. But when the app continues after evaluating just viewDidLoad
printed in the debug console won't tell which Class was called. viewDidLoad
could be in every ViewController. So I add the class name to identify the location (see image).
To avoid having to type the full class name I use initials:
MGA_OneViewController
becomes OVC
The OVC %B
produces the output
OVG -viewDidLoad
and now the Class is known.
Typing three (or a few) letters is not a problem but is does require discipline to ensure the same acronym is used through out the class.
I found a nice syntax but that is even longer, Craig uses
p (void)NSLog(@"%s: %@", _cmd)
Some related SO questions (16661758, 12695845) all use a rather long command, too long for me to remember.
So my questions are: is the there a percent shortcut for the class name? A Percent-F
maybe?
Alternatively, is it possible to create a breakpoint template that will contain the expressions ready made?
I use @[self class]@ %B
which, although not a formatter, may be a little more compact than the alternatives listed in the original question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With