Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Breakpoint: shortcut for file name or class name

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

Breakppint with Log Message "OVC %B"

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?

like image 598
Olaf Avatar asked Nov 02 '22 05:11

Olaf


1 Answers

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

like image 65
FaisalM Avatar answered Nov 08 '22 08:11

FaisalM