Xcode 6 - 防止快速的操场刷新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25949171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:38:20  来源:igfitidea点击:

Xcode 6 - Prevent swift playground refresh

xcodeswiftxcode6swift-playground

提问by Alex

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.

每次 Playground 想要刷新结果时,它都必须运行那段代码(这需要一段时间才能运行),这使得 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 说:“现在不要运行我的游乐场。我会在它准备好时告诉你。”?

回答by R. Gordon

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.screenshot

在 Xcode 7 中,您可以通过单击并按住 ? 操场左下角的箭头。截屏

Documentation link

文档链接

回答by Jason Rybka

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.

我不知道这样做的官方方法,但是...如果您在操场底部留下多行注释并且不添加结束 */ 标记,则在添加结束标记之前它不会运行。