Cri*_*tik 2 debugging xcode breakpoints lldb swift
基本上,我需要在协议方法上设置一个断点,以捕获对符合该协议的对象的所有调用。我有一个自定义框架,其中包含许多符合协议的类,因此在每个类上手动设置断点是不可行的。
我尝试从Xcode编辑器设置断点:
,并且正如预期的那样,调试器在doSomething()被调用时不会停止。
以下是一些演示代码来说明这一点:
protocol TestProtocol {
func doSomething()
func doAnotherThing()
}
class TestConformingClass: TestProtocol {
func doSomething() {
print("Yay")
}
func doAnotherThing() {
print("Hooray")
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法拦截对协议要求列表中一部分方法的所有调用?
在lldb中运行以下命令应该可以解决问题:
breakpoint set --name doSomething
breakpoint set --name doAnotherThing
Run Code Online (Sandbox Code Playgroud)
甚至,以下情况也可能有效:
breakpoint set --name doSomething --name doAnotherThing
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
427 次 |
| 最近记录: |