2015-10-21 42 views
2

我在Xcode 7.1使用游乐场(测试版3),但具有与所述captureValue()功能麻烦:使用的Xcode游乐场captureValue()

captureValue:withIdentifier:捕获一个值与 指定标识符被显示在时间轴上。

宣言

公共FUNC captureValue(价值:T,withIdentifier标识符: 字符串)

— Apple Developer Site

当我调用该函数,我得到的是这样的:

captureValue

如何使用captureValue?或者这是测试版3中的错误?

回答

5

captureValue()显示您在时间轴中捕获的值,该时间轴是游乐场的助理编辑器中显示的单独视图。 (您可以通过按下Command-Option-Return来显示助手编辑器。)您显示的是当前行的结果,该行自captureValue()返回Void后,就是XCPlaygroundPage本身。

这里的时间表应该是什么样子:

Playground Timeline

+1

PS:'XCPlaygroundPage.currentPage.liveView = yourUIViewInstance' – ChildhoodAndy

+0

相信方法现在已经过时 –

4

不过,如果你想在操场上,而不是一个转储列表一个很好的情节,你需要在一个循环分配CaptureValue

for var i in 1...12 { 
    XCPlaygroundPage.currentPage.captureValue(i*i*i, withIdentifier: "Cube") 
} 

的Xcode 7.2

Playground with a nice cube plot from 1 to 12

+1

好像弃用的Xcode 7.3的 –