Xcode Breakpoint: shortcut for file name or class name

debugging, ios, iphone, objective-c, xcode

Solution

I use `@[self class]@ %B` which, although not a formatter, may be a little more compact than the alternatives listed in the original question.

Problem

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?

Original source