如何使用 swift playground 打印到控制台? [英] How to print to console using swift playground?
问题描述
我一直在关注 Apple 的新语言 swift 指南,但我不明白为什么右边的栏只显示你好,游乐场"而不是你好,世界".有人可以解释为什么 println
没有打印在右侧吗?
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?
// Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
println("Hello, world");
推荐答案
在 Xcode 6.3 及更高版本(包括 Xcode 7 和 8)中,控制台输出出现在 Playground 窗口底部的 Debug 区域(类似于它出现的位置)在一个项目中).显示它:
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:
菜单:查看 >调试区显示调试区 (⌘⇧Y)
Menu: View > Debug Area > Show Debug Area (⌘⇧Y)
点击工具栏中工作区布局小部件的中间按钮
Click the middle button of the workspace-layout widget in the toolbar
点击窗口底部时间轴旁边的三角形
Click the triangle next to the timeline at the bottom of the window
任何写入控制台的内容,包括 Swift 的 print
语句(从 Swift 2 beta 中的 println
重命名)都会显示在那里.
Anything that writes to the console, including Swift's print
statement (renamed from println
in Swift 2 beta) shows up there.
在早期的 Xcode 6 版本中(现在您可能应该从任何版本升级),显示助手编辑器(例如,通过单击输出区域中某个位旁边的小圆圈).控制台输出出现在那里.
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.
这篇关于如何使用 swift playground 打印到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!