我已经在接口(interface)中声明了一个全局数组/字典,如下所示。
@interface ViewController ()
{
NSDictionary *dictionary;
NSArray *array;
}
我正在执行 API 调用并将值存储在这些数组和字典中。我想在运行时打印 LLDB 中的数组/字典的内容。
当我尝试打印这些全局变量时,它给了我以下错误。
(lldb) po assigneeArr
error: warning: Stopped in a context claiming to capture an Objective-C object pointer, but 'self' isn't available; pretending we are in a generic context
error: use of undeclared identifier 'assigneeArr'
error: 1 errors parsing expression
那么我该如何调试这个全局声明的变量呢?
最佳答案
这些不是全局变量;它们是实例变量,因此您需要 ViewController
的实例在你看到它们的值(value)之前。
一旦你有了实例,它就像使用 ->
一样简单。运算符(vc
是实例):
po vc->dictionary
注意:我建议使用下划线作为实例变量名称的前缀,以避免与参数和局部变量混淆。
关于ios - 如何在 LLDB 中调试成员变量(即 Array、Dictionary)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36468615/