我常用的都在這里了
- 給指定的地址加斷點
watchpoint set expression -- 0x7ff1af665390
- 給變量加斷點
watchpoint set variable
- 自動給類里面每個方法加斷點
breakpoint set -r '\[ClassName .*\]$'
- 找到響應事件的類
po [(0x7ff1af665390) allTargets];
{(
<XXXClass: 0x7ff1b1037000; baseClass = UITableViewCell; frame = (0 65; 375 150); autoresize = W; layer = <CALayer: 0x608000626a80>>,
<XXXClass: 0x60000001c750>
)}
- 找到響應事件的方法
po [(0x7ff1af665390) actionsForTarget:(id)0x7ff1b1037000 forControlEvent:0];
<__NSArrayM 0x600000a5f920>(
XXXMethod:
)
- 打印對象的內(nèi)容
p *((XXXClass *)0x7fb2fc601e40)
- 打印對象屬性的內(nèi)容
p *((XXXClass *)0x000060800044ccc0).XXXProperty
- 改變某個view的屬性
//e.g.臨時改變view的顏色
expr aView.backgroundColor = [UIColor redColor];
- 打印對象地址
po object
- 打印所有通知中心的觀察者
po [NSNotificationCenter defaultCenter]
拋磚引玉,大家自由發(fā)揮。更多命令可以去lldb官方網(wǎng)站查看
//official website
https://lldb.llvm.org/
//about custom command
https://stackoverflow.com/questions/12829665/how-to-call-methods-or-execute-code-in-lldb-debugger
//about swift
https://stackoverflow.com/questions/37390238/how-can-i-set-lldbs-default-language-to-swift