Questions tagged [swift-playground]

Swift Playgrounds are interactive design environments that evaluate code as you write it. Intermediate results of the code are shown in a right-hand pane.

Swift playgrounds are interactive documents where Swift code is compiled and run live as you type. Results of operations are presented in a step-by-step timeline as they execute, and variables can be logged and inspected at any point. Playgrounds can be created within an existing Xcode project or as standalone bundles that run by themselves.

Playgrounds provide a great opportunity to document functions and library interfaces by showing syntax and live execution against real data sets. For the case of the collection functions, we’ve created the CollectionOperations.playground, which contains a list of these functions, all run against sample data that can be changed live.

Playgrounds allow you to edit the code listings and see the result immediately.

The new playgrounds are especially useful for educators. You can insert rich instructional content with paragraph headings, diagrams, and links to additional material alongside the interactive Swift code.

New features in Xcode 6.3 playgrounds include the following:

  • Inline results display the output of your Swift code within the main editor window. The results area can be resized and configured to show different views of the output.

  • Stylized text is easy to add to your playground by adding special markup to your comments based on the familiar Markdown syntax. Some available styles are headings, bold, italic, lists, bullets, and links to external or bundled resources.

  • The Resources folder bundles images and other content directly within the playground. These resources can be accessed from your Swift code or from the rich comments within the playground. (Note: with Xcode 6.3 beta 2 use Show Package Contents in Finder to drag files into the playground’s Resources folder.)

Apple provides documentation here:

1311 questions
0
votes
1 answer

swift support for comma operator?

The following code seems to work just fine in swift: for (var i = 0, x = 0; i < 10; i++, x++) { println ("i is \(i) x is \(x)"); } 1) I can not find any documentation that says the comma operator is supported or not. 2) The swift-playground…
Bill
  • 1,588
  • 12
  • 21
0
votes
3 answers

Typecast Obligation is Apple Swift

Am I missing something or typecast is obligatory while adding numbers having different types: var i:Int=5 var d:Double=6.0 var q:Double= i + d // this is error?! var w:Double= Double(i) + d // this is ok
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
0
votes
2 answers

Initilizing a two dimensional array in Swift

I have defined a two dimensional array as : var monthNames:[[String]] I want to initialize it as following: Number of columns: 3, and rows of each column: undefined so I can init rows later.
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
0
votes
1 answer

ios8 playground editor not visible

I am not able to see editor screen for .playground file in Xcode 6.0. Here it only shows ENTITY MAPPINGS screen: How to switch to editor, Tried lot but not able to find in menu. Other thing is that even if i trying close this file it shows message…
Kampai
  • 22,848
  • 21
  • 95
  • 95
0
votes
2 answers

Take a look at this code and let me know if there's anything I can change

I asked a questions yesterday and received an awesome answer that solved most of my problem. I was trying to pair specific numeric values with 11 colors that were assigned at increments of 12 and shapes that where repeated every 12 increments. ex:…
0
votes
1 answer

Creating a UIManagedDocument in Swift Playground - signal SIGABRT error

I am new to coding and attempting to build my first app. I am trying to create a UIManagedDocument using Swift Playgrounds by following the steps outlined in the CS193 Standford iOS course from last year, lecture 12. They are in objective C and I…
0
votes
1 answer

Swift Generics Console Output

After I enable this class inside Playground I am Losing all the Console Output written above this class. What is wrong with this ? and weirdly it is showing an error 'Expected Pattern' at the switch statement for sometime and later the error goes…
0
votes
1 answer

Why does UInt32(stringArray.count) count wrong in a function but correct alone in swift playground?

Why does this code count 6 elements, as 9 ("wrong") in swift playground. var stringArray = ["1", "2", "3", "4", "5", "6"] for var i = 0; i < 3; i++ { stringArray.append("Paragraph" + "\(i)") } func concat (array: [String]) -> String { let…
KML
  • 2,302
  • 5
  • 26
  • 47
0
votes
1 answer

Using Swift classes in playground

I'm playing with Swift; I downloaded https://github.com/FahimF/SQLiteDB and, when called from .swift file it runs fine ..I connect and get query results as: let db = SQLiteDB.sharedInstance() if let data = db.query("SELECT * FROM…
Cris
  • 12,124
  • 27
  • 92
  • 159
0
votes
2 answers

How to declare "if optional" on for a stack on Swift

I can't quite figure out how to declare "if optional" on a stack using class on Swift. Here's the generic code that I have for a stack on Swift using class (the book uses struct but I was told to use class). class Stack { var items =…
Chrine
  • 57
  • 1
  • 7
0
votes
2 answers

Swift Playground Error: Couldn't lookup symbols:_CGPointMake

I'm trying to get a Live View to work in a Swift Playground. Whenever I import the XCPlayground framework to execute the XCPShowView function i get this error: Playground execution failed: error: Couldn't lookup symbols:_CGPointMake The error…
dcbenji
  • 4,598
  • 5
  • 21
  • 23
0
votes
1 answer

swift how to parse complex json?

Here is my method for parsing JSON var apiUrl = NSURL(string: "http://127.0.0.1/api.php") var apiData = NSData.dataWithContentsOfURL(apiUrl, options: NSDataReadingOptions.DataReadingUncached, error: nil) var apiJson =…
小弟调调
  • 1,315
  • 1
  • 17
  • 33
0
votes
1 answer

Swift deal cards to players from set array of "cards"

I have an array called shuffledDeck that holds 52 Int numbers shuffled I want to deal to each player individually func dealCards1(){ for i in 0...25{ comp1PlayDeck += shuffledDeck[i] } } Not quite sure what I should return I am…
arcreigh
  • 1,423
  • 2
  • 11
  • 12
0
votes
1 answer

Using Type T in swift Playground

I am trying to follow along with the playground video on the WWDC page, but for some reason I am getting this error now. I switch to beta 3 of Xcode 6 and I noticed they changed some stuff, such as array syntax but why can't by Type T work? I'm…
domshyra
  • 933
  • 3
  • 11
  • 28
0
votes
1 answer

Swift UITableView : Datasource assigning Issue

This is a simple UITableView code that is working correctly in playground: import UIKit class MyDataSuorce : NSObject, UITableViewDataSource { func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) ->…
Emadpres
  • 3,466
  • 2
  • 29
  • 44