【问题标题】:How do I quickly inspect the value of an arbitrary variable in Xcode 4.6.x?如何在 Xcode 4.6.x 中快速检查任意变量的值?
【发布时间】:2013-04-13 13:43:14
【问题描述】:

it is slow to use the po command in Xcode 4.6.x 似乎得到了广泛的认可。有哪些选项可以检查编译时未指定的任意变量的值(这排除了 NSLog() 的使用)不超过 15 秒?

【问题讨论】:

  • 通过标记断点,并将鼠标指针移动到该变量
  • @AnoopVaidya 没有骰子 - 见here
  • 弹出窗口是怎么来的?右键单击?
  • 不只是将鼠标悬停在变量上并单击箭头。你用的是 4.6 吗?
  • 是的......它应该工作。检查不同系统上的其他一些 XCode。符合要求,然后重新安装 XCode。

标签: xcode debugging xcode4.6


【解决方案1】:

只需在要了解变量值的位置设置断点即可。一旦程序暂停,所有变量值的摘要将出现在屏幕左下角的Varibles view 上。这是截图:

【讨论】:

  • 你试过用 Xcode 4.6 做这个吗?右键单击该窗格中的一个变量最多有 30 秒的延迟,更不用说对象、ivars 等了。
  • 嗯,我使用的是 4.6.1,右键单击时完全没有延迟。为什么要右键单击?您无需单击即可获得值。
  • 如果是字典呢?还是您要检查的 ivar?
  • 我有一个包含 3 个键/值对的小字典,仍然没有任何滞后或延迟。
【解决方案2】:

您可以使用 lldb 命令:

p (int) myInt
po myObject
po myObject.memberObject
p (float) myObject.floatMember

请注意,您也可以在最新版本的 Xcode 中使用 p 代替 po。如果您在 llb 中运行 help -a,它将为您提供命令别名,下面是您可以使用的命令的 sn-p。

> (lldb) help -a  
p         -- ('expression --')  Evaluate a C/ObjC/C++ expression in the current
         program context, using user defined variables and variables
         currently in scope.  

po        -- ('expression -o  --')  Evaluate a C/ObjC/C++ expression in the
         current program context, using user defined variables and
         variables currently in scope  

print     -- ('expression --')  Evaluate a C/ObjC/C++ expression in the current
         program context, using user defined variables and variables
         currently in scope.

【讨论】:

【解决方案3】:

原来答案很简单:下载 Xcode 4.6.2,LLDB 调试速度显着提高。注意一些关于here的讨论

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    • 1970-01-01
    • 1970-01-01
    • 2011-09-03
    相关资源
    最近更新 更多