获取操场以显示所有循环结果

时间:2015-10-23 01:26:53

标签: swift swift2 xcode7 swift-playground

我正在使用xcode 7游乐场,我想知道如何让游乐场显示循环打印出的所有结果。

例如:

enter image description here

这将告诉我循环运行4次,但它只显示迭代的最后一个值。有没有办法让它显示所有值?

4 个答案:

答案 0 :(得分:34)

右键单击内联快速查看(灰色圆角矩形,其中包含" 4")。可以选择在列表中显示所有结果:

Value History

您还可以通过点击左下角的show debug area按钮,向整个游乐场执行显示已打印到控制台的所有内容:

enter image description here

答案 1 :(得分:3)

在xcode 7中,右键单击显示框上的鼠标将为您提供正确的下拉菜单。 然而按住Ctrl键并单击并使用Macbook上的触控板会给出正确的下拉菜单。您必须在Editor菜单下选择它。

这个bug在xcode 7.1中消失了

enter image description here

答案 2 :(得分:2)

我附上GIF图像以显示游乐场代码的执行结果。 GIF Animation

答案 3 :(得分:0)

您可以直接在调试区域

上查看结果

enter image description here

<强>(或)

点击定义print方法的行上的任意位置,然后按照以下步骤

 1. Editor -> Show Results for Current Line Editor
 2. Editor -> Result Display Mode -> Value History

反之亦然,您可以隐藏print详细信息

 Editor -> Hide Results for Current Line

enter image description here