ios - 如何在 LLDB 中调试成员变量(即 Array、Dictionary)?

标签 ios xcode lldb

我已经在接口(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

那么我该如何调试这个全局声明的变量呢?

enter image description here

最佳答案

这些不是全局变量;它们是实例变量,因此您需要 ViewController 的实例在你看到它们的值(value)之前。

一旦你有了实例,它就像使用 -> 一样简单。运算符(vc 是实例):

po vc->dictionary

注意:我建议使用下划线作为实例变量名称的前缀,以避免与参数和局部变量混淆。

关于ios - 如何在 LLDB 中调试成员变量(即 Array、Dictionary)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36468615/

相关文章:

ios - dispatch_barrier_async 不等待 CoreImage 完成处理

ios - 如何在 swift 中使用 segue 发送用户信息以查看 Controller ?

xcode - 如何将文件添加到 Xcode 项目? (编写Unity插件)

ios - 具有自定义 URLSessionConfiguration 的 Google map iOS SDK

iOS 二分搜索代码在超过 256 项时崩溃

iphone - 如何向页面 Controller 添加按钮

swift - UITableViewCell 加载错误的 CAShapeLayer 形状

swift - LLDB 快速打印对象

linux - 在 Linux 上的 lldb 中打开 .NET Core 2.0 转储 - 哪个 lldb 版本?

swift - 如何获取 JSON 格式的 Swift REPL 编译器错误