简体   繁体   中英

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 与日志消息“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?

我使用@[self class]@ %B ,虽然它不是格式化程序,但可能比原始问题中列出的替代方案更紧凑。

为了快速,您可以使用

@type(of:self)@

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM