ios - 有没有比手动 po 每个变量更好的方法来检查协议(protocol)中 swift 对象的属性?

标签 ios swift debugging protocols

我有这个代码

public protocol UserItemModel {
    var identifier: String { get }
    var type: UserItemModelType { get }
    var isSelectable: Bool { get }
    var isActionable: Bool { get }
}

final class SampleItemModel: UserItemModel {
    let identifier: String
    var type: UserItemModelType
    var isSelectable: Bool
    var isActionable: Bool

    init(identifier: String = UUID().uuidString, 
         type: UserItemModelType = .user(SampleUserModel()), 
         isSelectable: Bool = false, 
         isActionable: Bool = true) {
        self.identifier = identifier
        self.type = type
        self.isSelectable = isSelectable
        self.isActionable = isActionable
    }
}

当我用断点调试它时,显示的值是这个。

enter image description here

始终是payload_xxx,我检查该值的唯一方法是手动使用各个属性。当我调试 [UserItemModel] 时,情况更糟。

有没有办法让所有属性直接显示在变量 Pane 中?就像 Objective-C 中一样。

谢谢。

最佳答案

尝试全局 dump(_:name:indent:maxDepth:maxItems:)功能。

expr dump(itemModel)

此外,LLDB 可以通过 Python 进行高度脚本化,因此您也可以研究一下

关于ios - 有没有比手动 po 每个变量更好的方法来检查协议(protocol)中 swift 对象的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58128249/

相关文章:

ios - 在 Tableview 的编辑模式下禁用 TextField

android - React Native Android 在启用 Debug模式时崩溃

c# - 在调试器中跳过一个方法,但之后继续正常调试

swift - 不要用 Xcode 8 复制 swift 库?

java - 在 Eclipse Debugger 中,获取嵌入列表层次结构中变量的索引位置

ios - 函数在 Storyboard 加载之前开始

android - 如何将 cordova 项目从 visual studio (Hybrid App) 编译到 android/ios apk

iphone - UIButtonType删除常数

ios - 在 iPad 上编辑时编辑表格 View 缺少背景颜色

swift - CosmicMind/Material Textfield 的 PlaceHolder 在左 View 上