如何使用快速的操场打印控制台?

时间:2023-01-23 17:06:20

I have been following the Apple Guide for their new language swift, but I don't understand why the bar on the right is only showing "Hello, playground" and not "Hello, world". Can someone explain why the println isn't being printed on the right?

我一直在跟随Apple Guide的新语言swift,但我不明白为什么右边的酒吧只显示“你好,操场”,而不是“你好,世界”。有人能解释为什么println没有被打印在右边吗?

// Playground - noun: a place where people can play

import Cocoa

var str = "Hello, playground"

println("Hello, world");

如何使用快速的操场打印控制台?

7 个解决方案

#1


131  

In Xcode 6.3 and later (including Xcode 7 and 8), console output appears in the Debug area at the bottom of the playground window (similar to where it appears in a project). To show it:

在Xcode 6.3和稍后(包括Xcode 7和8)中,控制台输出出现在操场窗口底部的Debug区域(类似于在项目中出现的地方)。显示:

  • Menu: View > Debug Area > Show Debug Area (⌘⇧Y)
  • 菜单:查看>调试区>显示调试区域(Y)
  • Click the middle button of the workspace-layout widget in the toolbar

    单击工具栏中的workspacelayout小部件的中间按钮。

    如何使用快速的操场打印控制台?

  • Click the triangle next to the timeline at the bottom of the window

    单击窗口底部的时间轴旁边的三角形。

    如何使用快速的操场打印控制台?

Anything that writes to the console, including Swift's print statement (renamed from println in Swift 2 beta) shows up there.

任何写入控制台的内容,包括Swift的print语句(在Swift 2 beta中重命名为println)都显示在那里。


In earlier Xcode 6 versions (which by now you probably should be upgrading from anyway), show the Assistant editor (e.g. by clicking the little circle next to a bit in the output area). Console output appears there.

在早期的Xcode 6版本中(现在您可能应该升级了),显示辅助编辑器(例如,单击输出区域旁边的小圆)。控制台输出出现在那里。

#2


71  

you need to enable the Show Assistant Editor:

您需要启用Show Assistant编辑器:

如何使用快速的操场打印控制台?

#3


13  

Just Press Alt + Command + Enter to open the Assistant editor. Assistant Editor will open up the Timeline view. Timeline by default shows your console output.

只需按Alt + Command + Enter键打开辅助编辑器。助理编辑器将打开时间轴视图。默认的时间轴显示您的控制台输出。

Additionally You can add any line to Timeline view by pressing the small circle next to the eye icon in the results area. This will enable history for this expression. So you can see the output of the variable over last 30 secs (you can change this as well) of execution.

此外,您还可以将任何一行添加到时间轴视图中,通过在结果区域的眼睛图标旁边按下这个小圆圈。这将为这个表达式启用历史。因此,您可以看到变量在过去30秒内的输出(您也可以改变这一点)执行。

#4


11  

You may still have trouble displaying the output in the Assistant Editor. Rather than wrapping the string in println(), simply output the string. For example:

在辅助编辑器中显示输出可能仍然有问题。而不是将字符串包装在println()中,只需输出字符串。例如:

for index in 1...5 {
    "The number is \(index)"
}

Will write (5 times) in the playground area. This will allow you to display it in the Assistant Editor (via the little circle on the far right edge).

在操场上写作(5次)。这将允许您在助理编辑器中显示它(通过在最右边缘的小圆)。

However, if you were to println("The number is \(index)") you wouldn't be able to visualize it in the Assistant Editor.

但是,如果您要println(“number是\(index)”),您将无法在助理编辑器中看到它。

#5


2  

As of Xcode 7.0.1 println is change to print. Look at the image. there are lot more we can print out. 如何使用快速的操场打印控制台?

如Xcode 7.0.1 println是要打印的。看图片。我们可以打印出更多的东西。

#6


0  

move you mouse over the "Hello, playground" on the right side bar, you will see an eye icon and a small circle icon next it. Just click on the circle one to show the detail page and console output!

把鼠标移到右边栏上的“你好,操场”上,你会看到旁边有一个眼睛图标和一个小圆圈图标。只需点击圆圈,就可以显示详细的页面和控制台输出!

#7


0  

for displaying variables only in playground, just mention the variable name without anything

仅在操场上显示变量,只需在没有任何内容的情况下提到变量名。

let stat = 100

让统计= 100

stat // this outputs the value of stat on playground right window

stat //这将在操场右窗口输出stat的值。

#1


131  

In Xcode 6.3 and later (including Xcode 7 and 8), console output appears in the Debug area at the bottom of the playground window (similar to where it appears in a project). To show it:

在Xcode 6.3和稍后(包括Xcode 7和8)中,控制台输出出现在操场窗口底部的Debug区域(类似于在项目中出现的地方)。显示:

  • Menu: View > Debug Area > Show Debug Area (⌘⇧Y)
  • 菜单:查看>调试区>显示调试区域(Y)
  • Click the middle button of the workspace-layout widget in the toolbar

    单击工具栏中的workspacelayout小部件的中间按钮。

    如何使用快速的操场打印控制台?

  • Click the triangle next to the timeline at the bottom of the window

    单击窗口底部的时间轴旁边的三角形。

    如何使用快速的操场打印控制台?

Anything that writes to the console, including Swift's print statement (renamed from println in Swift 2 beta) shows up there.

任何写入控制台的内容,包括Swift的print语句(在Swift 2 beta中重命名为println)都显示在那里。


In earlier Xcode 6 versions (which by now you probably should be upgrading from anyway), show the Assistant editor (e.g. by clicking the little circle next to a bit in the output area). Console output appears there.

在早期的Xcode 6版本中(现在您可能应该升级了),显示辅助编辑器(例如,单击输出区域旁边的小圆)。控制台输出出现在那里。

#2


71  

you need to enable the Show Assistant Editor:

您需要启用Show Assistant编辑器:

如何使用快速的操场打印控制台?

#3


13  

Just Press Alt + Command + Enter to open the Assistant editor. Assistant Editor will open up the Timeline view. Timeline by default shows your console output.

只需按Alt + Command + Enter键打开辅助编辑器。助理编辑器将打开时间轴视图。默认的时间轴显示您的控制台输出。

Additionally You can add any line to Timeline view by pressing the small circle next to the eye icon in the results area. This will enable history for this expression. So you can see the output of the variable over last 30 secs (you can change this as well) of execution.

此外,您还可以将任何一行添加到时间轴视图中,通过在结果区域的眼睛图标旁边按下这个小圆圈。这将为这个表达式启用历史。因此,您可以看到变量在过去30秒内的输出(您也可以改变这一点)执行。

#4


11  

You may still have trouble displaying the output in the Assistant Editor. Rather than wrapping the string in println(), simply output the string. For example:

在辅助编辑器中显示输出可能仍然有问题。而不是将字符串包装在println()中,只需输出字符串。例如:

for index in 1...5 {
    "The number is \(index)"
}

Will write (5 times) in the playground area. This will allow you to display it in the Assistant Editor (via the little circle on the far right edge).

在操场上写作(5次)。这将允许您在助理编辑器中显示它(通过在最右边缘的小圆)。

However, if you were to println("The number is \(index)") you wouldn't be able to visualize it in the Assistant Editor.

但是,如果您要println(“number是\(index)”),您将无法在助理编辑器中看到它。

#5


2  

As of Xcode 7.0.1 println is change to print. Look at the image. there are lot more we can print out. 如何使用快速的操场打印控制台?

如Xcode 7.0.1 println是要打印的。看图片。我们可以打印出更多的东西。

#6


0  

move you mouse over the "Hello, playground" on the right side bar, you will see an eye icon and a small circle icon next it. Just click on the circle one to show the detail page and console output!

把鼠标移到右边栏上的“你好,操场”上,你会看到旁边有一个眼睛图标和一个小圆圈图标。只需点击圆圈,就可以显示详细的页面和控制台输出!

#7


0  

for displaying variables only in playground, just mention the variable name without anything

仅在操场上显示变量,只需在没有任何内容的情况下提到变量名。

let stat = 100

让统计= 100

stat // this outputs the value of stat on playground right window

stat //这将在操场右窗口输出stat的值。