Xcode ships with both a command-line interpreter (which was covered in Chapter 1, Exploring Swift) and a graphical interface called playground that can be used to prototype and test Swift code snippets. Code that is typed into the playground is compiled and executed interactively, which permits a fluid style of development. In addition, the user interface can present a graphical view of variables as well as a timeline, which can show how loops are executed. Finally, playgrounds can mix and match code and documentation leading to the possibility of providing example code as playgrounds and using playgrounds to learn how to use existing APIs and frameworks.
This chapter will present the following topics:
How to create a playground
Displaying values in the timeline
Presenting objects with Quick Look
Running asynchronous code
Using playground's live documentation
Creating multiple pages in a playground
Limitations of playgrounds