【问题标题】:why does lldb's po command can't print superview in dot?为什么lldb的po命令不能在dot中打印superview?
【发布时间】:2015-12-02 09:29:37
【问题描述】:

如果我想要 po subView 的 superview ,当我使用 subView.superView 时,它会抱怨 not found ,但是如果我使用 [subView superView] , po 命令可以正常工作,这背后的原因是什么?

(lldb) po self.blackView.superview
error: property 'superview' not found on object of type 'UIView *'
error: 1 errors parsing expression
(lldb) po ((UIView*)self.blackView).superview
error: property 'superview' not found on object of type 'UIView *'
error: 1 errors parsing expression
(lldb) po [self.blackView superview]
<UIView: 0x15d53ce50; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x15d53cfc0>>

【问题讨论】:

  • 您使用的是哪个 XCode 版本?
  • LLDB 在使用多个点时会出现解析问题。第一个会起作用,而后一个不会。
  • 使用@Leo Xcode 7.1

标签: ios objective-c xcode lldb


【解决方案1】:

一般来说,它们并不是真正解析问题,它们往往是“类型信息质量”问题。在这种情况下,superview 实际上是 UIViewHierarchy 类别上的一个属性,并且 clang 的调试信息中存在一个错误,导致它不会为类别中的属性生成调试信息。除非编译器知道类型,否则编译器不会将属性访问转换为方法调用。

如果您使用 Xcode7,通常可以通过指示 lldb 为感兴趣的框架构建模块来解决使用 clang“模块”功能的框架(包括大多数 Apple 框架)的这种类型信息问题,该框架具有更丰富的类型信息。您可以通过发出 lldb 命令来执行此操作:

(lldb) expr @import UIKit

在尝试你的表达式之前尝试运行它,看看是否会更好。

【讨论】:

    猜你喜欢
    • 2013-09-23
    • 2014-11-21
    • 2014-03-21
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多