LLDB:查看 UIModalPresentationStyle 枚举的实际值
LLDB: view real value of the UIModalPresentationStyle enum
在为 UIViewController
实例的方法设置断点进行调试时,我决定检查 UIModalPresentationStyle
.
的值
这是我得到的:
(lldb) po self.modalPresentationStyle
__C.UIModalPresentationStyle
如何获取变量的真实值,而不是其类型?
我可以 "reverse-engineer" 通过执行以下命令:
(lldb) po self.modalPresentationStyle == .fullScreen
false
但是怎样才能更快地达到预期的效果呢?
经过一些实验,我也无法让 LLDB 从枚举中打印符号值。但是,对于这种情况,有一种中途选择:
po self.modalPresentationStyle.rawValue
你至少可以得到枚举中位置的数值,要么看看枚举定义,要么记住关键值,以匹配你得到的数字。对于字符串枚举,结果会更清楚。
po
命令要求对象提供对自身的描述。我不确定为什么 UIModalPresentationStyle 的 swift 对象描述只打印它的类型。这可能值得一个 swift 错误。
但是,如果您要求 lldb 为您评估表达式和 return 它的值 - 而不是呈现该值的对象的描述 - 使用:
(lldb) p self.modalPresentationStyle
(UIModalPresentationStyle) $R0 = fullScreen
您有时会得到更有用的答案。
在为 UIViewController
实例的方法设置断点进行调试时,我决定检查 UIModalPresentationStyle
.
这是我得到的:
(lldb) po self.modalPresentationStyle
__C.UIModalPresentationStyle
如何获取变量的真实值,而不是其类型?
我可以 "reverse-engineer" 通过执行以下命令:
(lldb) po self.modalPresentationStyle == .fullScreen
false
但是怎样才能更快地达到预期的效果呢?
经过一些实验,我也无法让 LLDB 从枚举中打印符号值。但是,对于这种情况,有一种中途选择:
po self.modalPresentationStyle.rawValue
你至少可以得到枚举中位置的数值,要么看看枚举定义,要么记住关键值,以匹配你得到的数字。对于字符串枚举,结果会更清楚。
po
命令要求对象提供对自身的描述。我不确定为什么 UIModalPresentationStyle 的 swift 对象描述只打印它的类型。这可能值得一个 swift 错误。
但是,如果您要求 lldb 为您评估表达式和 return 它的值 - 而不是呈现该值的对象的描述 - 使用:
(lldb) p self.modalPresentationStyle
(UIModalPresentationStyle) $R0 = fullScreen
您有时会得到更有用的答案。