Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 - Prevent swift playground refresh

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.

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."?

like image 422
Alex Avatar asked Sep 20 '14 13:09

Alex


2 Answers

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

Documentation link

like image 132
R. Gordon Avatar answered Nov 01 '22 18:11

R. Gordon


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.

like image 32
Jason Rybka Avatar answered Nov 01 '22 18:11

Jason Rybka