Sometimes I'm writing some code on a playground that takes a while to complete. For example:
有时我在操场上写一些代码,需要一段时间才能完成。例如:
var values = [[Int]](count: 10000, repeatedValue: [Int](count: 73, repeatedValue: 0))
And everytime the playground wants to refresh the results, it has to run that piece of code (that takes a while to run) and it makes Xcode as a whole very sluggish.
而且,每当游乐场希望刷新结果时,它必须运行那段代码(这需要一段时间才能运行),这使得Xcode作为一个整体非常缓慢。
I still want to be writing my code on a playground since it has some very nice features for testing your algorithms. However, I'm finding that I have to comment certain lines of code just to continue writing without interruptions.
我仍然想在操场上写代码,因为它有一些非常好的特性来测试你的算法。但是,我发现我必须对某些代码行进行注释,以便在不中断的情况下继续写。
Is there any way to say to Xcode: "Do not run my playground right now. I'll tell you when it's ready."?
有没有办法对Xcode说:“现在不要跑我的游乐场。”等一切准备好了我再告诉你。”
2 个解决方案
#1
#2
5
I don't know an official way to do this but... If you leave a multiline comment at the bottom of the playground and do not add the closing */ tag it will not run until the closing tag is added.
我不知道官方的做法,但是…如果您在游乐场的底部留下一个多行注释,并且不添加结束*/标记,那么在添加结束标记之前,它将不会运行。
#1
64
In Xcode 7, you can choose between automatic or manual execution of a playground by clicking and holding the ► arrow at the bottom left part of the playground.
在Xcode 7中,您可以选择自动或手动执行的操场上点击并持有►箭头底部离开操场的一部分。
文档链接
#2
5
I don't know an official way to do this but... If you leave a multiline comment at the bottom of the playground and do not add the closing */ tag it will not run until the closing tag is added.
我不知道官方的做法,但是…如果您在游乐场的底部留下一个多行注释,并且不添加结束*/标记,那么在添加结束标记之前,它将不会运行。