【问题标题】:LLDB: view real value of the UIModalPresentationStyle enumLLDB:查看 UIModalPresentationStyle 枚举的实际值
【发布时间】:2019-03-25 02:40:11
【问题描述】:
在为UIViewController 实例的方法设置断点进行调试时,我决定检查UIModalPresentationStyle 的值。
这是我得到的:
(lldb) po self.modalPresentationStyle
__C.UIModalPresentationStyle
如何获取变量的 REAL 值,而不是其类型?
我可以通过执行以下命令对其进行“逆向工程”:
(lldb) po self.modalPresentationStyle == .fullScreen
false
但是我怎样才能更快地达到预期的效果呢?
【问题讨论】:
标签:
ios
xcode
debugging
lldb
【解决方案1】:
po 命令询问对象对其自身的描述。我不确定为什么 UIModalPresentationStyle 的快速对象描述只是打印它的类型。这可能值得一个快速的错误。
但是,如果您要求 lldb 评估表达式并为您返回其值 - 而不是呈现该值的对象描述 - 使用:
(lldb) p self.modalPresentationStyle
(UIModalPresentationStyle) $R0 = fullScreen
你有时会得到更有用的答案。
【解决方案2】:
经过一些实验,我也无法让 LLDB 从枚举中打印符号值。但是,对于这样的情况,有一种中途选择:
po self.modalPresentationStyle.rawValue
你至少可以得到枚举中位置的数值,要么查看枚举定义,要么记住键值来匹配你得到的数字。对于字符串枚举,结果会更清晰。