在 Xcode 中观察表达式
说我正在调试。假设我需要知道 [somevariable count] 的值是多少,
我该怎么做?
Say I am debugging. Say I need to know what the value of [somevariable count]
How would I do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要在程序执行停止时知道表达式的值,请执行类似
在 gdb 控制台中的操作。
注意:
搜索“监视”一词的人们可能期望得到有关能够观察值何时发生变化的答案。对于这个问题,有一些更合适的答案:
在 Xcode 中观察变量
Xcode LLDB 观察点
If what you want to do is know the value of the expression while program execution is halted, then do something like
in the gdb console.
Note:
People searching for the term "watch" might be expecting an answer about being able to observe when a value changes. For that question these are some answers that are more appropriate:
Watching variables in Xcode
Xcode LLDB watchpoints
在相关代码行上放置断点。
当Xcode停在该行时,在调试区域(屏幕底部分为两部分,看右边的部分,如果没有看到底部部分,shift+cmd+Y,有时加上右侧或者左侧被隐藏,右下侧有小按钮可以显示它们),您会看到所有本地和全局变量。
右键单击(或两根手指)该调试区域,您将看到一个上下文菜单,其中包含“添加表达式”选项之一。
输入你的表情。
笔记:
对于来自任何其他 IDE 但不是 Xcode 的人来说,上面关于“watch”这个词的评论是非常清楚的。
Put a breakpoint on the relevant code line.
When Xcode stops on that line, in the debug area (the bottom of the screen is splitted to two parts, look at the right one, if you don't see the bottom part, shift+cmd+Y, plus sometimes the right side or the left side are hidden and there are small buttons on the right bottom side to show them), you see all of the local and global variables.
Right click (or two fingers) that debug area, and you will see a context menu with one of the options "add expression".
Type in your expression.
Note:
above previous user's comment about the word "watch" is pretty clear to whomever comes from any other IDE but not in Xcode.