【问题标题】:NSIndexPath: a useful lldb summary stringNSIndexPath:一个有用的 lldb 摘要字符串
【发布时间】:2014-03-24 08:20:15
【问题描述】:

在 Xcode 中使用 lldb 进行调试时,我希望在调试器窗口中看到 NSIndexPath 对象的简单摘要字符串。比如:

indexPath = (NSIndexPath *) { section=2 : row=0 }

会比 lldb 默认显示的内容更有帮助:

indexPath = (NSIndexPath *) [NSIndexPath * @ scalar section]

我确实尝试了许多将摘要字符串格式化程序写入我的 .lldbinit 文件,其中包括:

类型摘要添加 NSIndexPath --summary-string '${var.section}'

类型摘要添加 NSIndexPath --summary-string '${[var section]}'

类型摘要添加 NSIndexPath --summary-string '[${var section}]'

类型摘要添加 NSIndexPath --summary-string '[${var} section]'

前三个的结果是:

indexPath NSIndexPath * 错误:摘要字符串解析错误 0x08e309a0

最后一个是:

indexPath NSIndexPath * [NSIndexPath * @ scalar section] 0x08a45b80

这也没什么帮助。

你知道如何强制 lldb 为 NSIndexPath 显示一些更有用的摘要字符串吗?

【问题讨论】:

    标签: xcode string lldb summary nsindexpath


    【解决方案1】:

    (lldb) 类型摘要添加 NSIndexPath -s "${var%@}"

    这基本上会向您显示与

    相同的输出

    (lldb) po myIndexPath

    会 - 每次查看索引路径时都会运行表达式,这可能是也可能不是您想要的

    【讨论】:

    • 是的,这会产生以下输出:indexPath NSIndexPath * <NSIndexPath: 0x8c9c970> {length = 2, path = 1 - 1} 0x08c9c970。这并不完全是我梦寐以求的,但比默认输出更具交流性,并且为我省去了点击展开三角形以查看部分和行/项目的烦人。谢谢你:)
    猜你喜欢
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 2014-01-26
    • 2013-09-30
    • 2013-06-20
    • 1970-01-01
    • 2010-10-11
    • 2011-07-08
    相关资源
    最近更新 更多