APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Xcode 6 Playground


2014/11/19

Xcode 6 introduces a new programming language, Swift. You'll find all sorts of documentation and code on line, of course, but they have also given us an amazing tool called "Playground". This lets you type commands and see the results. It's a bit more than just having a Swift shell interpreter, though. You open up a new playground and type Swift commands into it. You get to see the results of your typing in a side window instantly. For example, if I type:


var mySpeed:Int = 69


if mySpeed < 70{
    println("Keep Cruising")
}
else {
    println("Slow down police ahead")
}
 

I'll get "Keep Cruising" in the side window. But that's barely the beginning. I can also type things like:

let myLabel=UILabel(frame:CGRectMake(0, 0, 150, 50))
myLabel.backgroundColor=UIColor.blueColor()

If I do that, a little inspector button appears in the right hand screen and look what that shows me:

Xcode 6 playground

It's actually showing me what the label would look like! Of course this is a simple case, but I never expected that.

Isn't that something? Even more amazing is that it's actually producing html files you could use to show off: see iOS 8: Interactive Playgrounds for more on that.



Got something to add? Send me email.




Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us