Since Apple released Swift, there is something new on Xcode---"Playground". Playground is like a playground where we can play in the world of code, and in this blog we'll show you how to use playground to quickly get started with swift programming. Playground in learning Swift language does play an important role, or that sentence, salted eggs here, the following cut into today's topic, how to create a playground, and how to use playground.
One. Create your own playground
Or use the previous Swiftdemo demo to create a playground that belongs to you.
1. Under the appropriate folder, right-click, select New File ..... As shown in the following:
2. After the first step you will see the following interface, we select Playground under source in iOS, and then click Next
3. Type the name of the playground you created, as shown below
4. Create a good playground as shown below
Second, play in the playground
1.Playground is what you see, that is, the code that you write on the left, you immediately see the result of the line running on the right, as shown below, a loop of 5 cycles is written, and the right side of the loop is immediately for-in: 5 times
2. You can click on the small white point behind the 5 times to view the loop in more detail, as shown in the click on the white point back to appear after the loop after the operation of the output on the console, and then every time the change in the index value of the loop, is not feel special like it.
Iii. Summary
Today's blog shows how to create a playground file in your project and how to use it to spy on the Swift language, and the next blog will use playground as a guide for more detailed snooping. Swift language more details, if for iOS development problems can be in the following message to Exchange learning, or join the QQ Exchange group above, common progress and improve. Look forward to some of the following swift tutorials, and finally to thank Tsinghua Publishing house for the "introduction of Swift Programming classic" translation work.
Spy on Swift programming and play on the playground