我有这个代码
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
}
}
当我用断点调试它时,显示的值是这个。
始终是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/