事半功倍的密语:lldb常用命令一览表
2018-12-31 本文已影响2人
溪石iOS

断点中止时,在Xcode底部调试窗口(如果没有显示按上图标示位置打开)
敲入以下命令:
po
:打印变量信息, 会调用对象的description方法(类似NSLog("%@", obj)
)
(lldb) po self.titleLabel
<UILabel: 0x7fc255525970; baseClass = UILabel; frame = (314 486; 80 80);
text = '分类'; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x600003e98690>>
expression
:运行时执行任意表达式,如:
(lldb) expression 1+1
(int) $4 = 2
当然也能执行赋值语句,用于运行时改变变量值:
(lldb) p self.view
(UIView *) $5 = 0x00007fc255613a70
(lldb) expression $5.backgroundColor = [UIColor redColor]
p
/e
:expression 的简略写法
(lldb) p self.titleLabel
(UILabel *) $8 = 0x00007fc255525970
(lldb) p self.view
(UIView *) $3 = 0x00007fc255708250
(lldb) e (void)[$3 setBackgroundColor:[UIColor redColor]]
由于中断会导致界面没有及时刷新,看不到改动效果,可以执行flush:
(lldb) e (void) [CATransaction flush]
bt
:打印主线程
调用堆栈,比左边图形化的更详细; bt all
将打印所有线程
。