【问题标题】:Unable to see console output in assistant editor using swift playground使用 Swift Playground 无法在助手编辑器中查看控制台输出
【发布时间】:2014-06-28 09:56:18
【问题描述】:

谁能解释一下,为什么控制台输出在助手编辑器中不可见。右侧的栏只显示“Hello, playground”,而助理编辑器显示为空白。

// Playground - 名词:人们可以玩耍的地方

   import UIKit

   var str = "Hello, playground"

   println("Hello")

   NSLog("Hello, world")

【问题讨论】:

标签: ios swift swift-playground


【解决方案1】:

你需要导入可可库:

import Cocoa

这个示例对我来说很好用:

import Cocoa

var str = "Hello, playground"
println("Hello")

NSLog("Hello, world")

【讨论】:

  • 你可能会得到这个异常Playground execution failed: error: <REPL>:5:8: error: no such module 'UIKit' import UIKit,如果你使用import UIKit
  • 因为你在Playground Settings中使用了Platform: OS X(目前是默认的,但是可以改成iOS,然后你必须导入UIKit)。
猜你喜欢
  • 2023-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-18
  • 2011-02-20
  • 2020-05-24
  • 2011-11-13
  • 1970-01-01
相关资源
最近更新 更多