本文介绍了您如何在视觉工作室的即时窗口中观看或评估xcode中的表达?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在MS视觉工作室中,我们只需右键单击添加手表。



如何在xcode中执行此操作?

解决方案

在调试区域使用 po 命令



设置在相关代码区域上的断点,当程序在断点处停止时,在调试区域的控制台中输入命令。
相关的命令是 po 打印对象),后跟要评估的表达式。 / p>

如果调试窗口在XCode中不可见,您可以通过顶部菜单显示:



'View' - > 调试区域 - > 激活控制台 XCode v8.x



示例



要评估一个表达式,如 var1 / var2 其中 var1 var2 都是双打,在控制台中输入以下内容:

  po var1 / var2 

控制台将返回以下内容:

 code>(double)$ 2 = 3.085 [no Objective-C description available] 



属性



您还可以在该断点处返回代码中当前使用的对象的特定属性:

  po [bankInfo city] 

它将返回以下内容:

 (id)$ 4 = 0x000069e8 Testville 

注意,尽管控制台似乎不喜欢点符号,并且在适用时更喜欢方括号。例如,这会给我一个错误:

  po bankInfo.city 
/ pre>

我希望这是你一直在寻找的。

In MS visual studio we just right click add watch.

How does one do this in xcode?

解决方案

Use the po command in the Debug area

Set up a breakpoint on the relevant area of code, then when the program stops at the breakpoint, enter commands in the Console in the Debug Area. The relevant command is po (print object) followed by the expression you want to evaluate.

If the Debug window is not visible in XCode, you can show it via the top menu:

'View' -> 'Debug Area' -> 'Activate Console' (XCode v8.x)

Example

To evaluate an expression like var1/var2 where var1 and var2 are both doubles, enter the following in the Console:

po var1/var2

The Console will return something like:

(double) $2 = 3.085 [no Objective-C description available]

Showing object properties

You can also return a particular property of an object currently used in the code at that breakpoint:

po [bankInfo city]

And it will return something like:

(id) $4 = 0x000069e8 Testville

Note though that the Console doesn't seem to like the dot notation and prefers the square brackets when applicable. For example, this returns an error for me:

po bankInfo.city

I hope this is what you've been looking for.

这篇关于您如何在视觉工作室的即时窗口中观看或评估xcode中的表达?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 01:39