如何在 Xcode 中添加 Watch 或 Inspect?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7145034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:46:45  来源:igfitidea点击:

How do I add a Watch or Inspect in Xcode?

objective-cxcode

提问by Java Ka Baby

as in the title is there a way in Xcode to Add Watch or Inspect a code segment in Xcode

如标题所示,Xcode 中有没有办法在 Xcode 中添加监视或检查代码段

for example how can I see the result of [myObject aMethod] with actually stepping over or Stepping in.

例如,我如何才能看到 [myObject aMethod] 实际跨过或跨入的结果。

回答by Suragch

To actually see the value change while you step through, you can right click the watch list of the debug area and choose "Add Expression..."

要在逐步执行时实际看到值的变化,可以右键单击调试区域的监视列表并选择“添加表达式...”

enter image description here

在此处输入图片说明

回答by jtbandes

In the debugger console, if you stop at a breakpoint you can type po [myObject aMethod]to see the return value (if it's not an idtype return value, use p ([return type here])[myObject aMethod]).

在调试器控制台中,如果在断点处停止,则可以键入po [myObject aMethod]以查看返回值(如果它不是id类型返回值,请使用p ([return type here])[myObject aMethod])。

You can also set a breakpoint action to print something out without pausing, just right click to edit the breakpoint:

您还可以设置断点操作以在不暂停的情况下打印一些内容,只需右键单击即可编辑断点: