使用 Xcode 游乐场 captureValue()
Using Xcode Playground captureValue()
我在 Xcode 7.1(测试版 3)中使用 Playgrounds,但在使用 captureValue()
功能时遇到问题:
captureValue:withIdentifier: Captures a value to be displayed with the
specified identifier in the timeline.
Declaration
public func captureValue(value: T, withIdentifier identifier:
String)
当我调用该函数时,我得到的是:
如何使用 captureValue?或者这是 beta 3 中的错误?
captureValue()
显示您在时间轴中捕获的值,时间轴是显示在 playground 的助理编辑器中的单独视图。 (您可以通过按 Command-Option-Return 来显示助理编辑器。)您显示的是当前行的结果,因为 captureValue()
returns Void
, 只是 XCPlaygroundPage
本身。
时间轴应该是这样的:
但是,如果你想在 playground 中有一个漂亮的情节而不是转储列表,你需要在循环中分配 CaptureValue
。
for var i in 1...12 {
XCPlaygroundPage.currentPage.captureValue(i*i*i, withIdentifier: "Cube")
}
Xcode 7.2
我在 Xcode 7.1(测试版 3)中使用 Playgrounds,但在使用 captureValue()
功能时遇到问题:
captureValue:withIdentifier: Captures a value to be displayed with the specified identifier in the timeline.
Declaration
public func captureValue(value: T, withIdentifier identifier: String)
当我调用该函数时,我得到的是:
如何使用 captureValue?或者这是 beta 3 中的错误?
captureValue()
显示您在时间轴中捕获的值,时间轴是显示在 playground 的助理编辑器中的单独视图。 (您可以通过按 Command-Option-Return 来显示助理编辑器。)您显示的是当前行的结果,因为 captureValue()
returns Void
, 只是 XCPlaygroundPage
本身。
时间轴应该是这样的:
但是,如果你想在 playground 中有一个漂亮的情节而不是转储列表,你需要在循环中分配 CaptureValue
。
for var i in 1...12 {
XCPlaygroundPage.currentPage.captureValue(i*i*i, withIdentifier: "Cube")
}
Xcode 7.2