- iOS 12 Programming for Beginners
- Craig Clayton
- 379字
- 2021-07-02 15:04:50
Playgrounds – an interactive coding environment
Before we jump into building the app that we will be creating in later chapters, called Let's Eat, we need to understand the basics of Swift. An easy way to experiment with Swift is to use Playgrounds. It is an interactive coding environment that evaluates your code and displays the results. Using Playgrounds gives us the ability to work with Swift without needing to create a project. It is great for prototyping a particular part of your app. So, whether you are learning or experimenting, Playgrounds are an invaluable tool. To create a Playground, we need to launch Xcode and click on Get started with a playground:

The Playground template screen appears. Make sure that you select iOS, and then choose Blank and hit Next:

You will be asked to give your project a name and a location to save the file; name your new project Playground iOS11-Programming-for-Beginners-Ch2. You can save the file anywhere that you like. Now, with the project saved, we can explore Playgrounds in a little more detail.
When you launch the app, you will see five distinct areas:

Let's break down each area in Playgrounds:
- Playground Editor: This area is where you write all of your code.
- Results Panel: The Results panel is a feature that's only found in Playgrounds and provides immediate feedback.
- Window Pane Controls: The Window Pane Controls have two groups of icons:

As we discussed earlier, the first group is called the Editor Mode, and the second group is called the View. Refer to the detailed description of these icons in the previous chapter for information about what each one does.
- Debug Toggle: This button allows you to hide and show the Debug panel and toggle on the Debug panel.
- Play/Stop: This button is used to make Playgrounds execute code or to stop Playgrounds from running. Typically, Playgrounds runs on its own, but sometimes you need to manually toggle this feature on when Playgrounds does not execute your code for you.
Now that we have the Xcode panels setup, delete all of the code in this file. Your Playground should have three open panels: your Playground Editor, the Results Panel, and the Debug Panel. Let's start digging into some code.
- Modern JavaScript Web Development Cookbook
- TCP/IP入門經典(第5版)
- 互聯網安全的40個智慧洞見:2015年中國互聯網安全大會文集
- Microservice Patterns and Best Practices
- Mastering Dart
- OMNeT++與網絡仿真
- 搶占下一個智能風口:移動物聯網
- 工業互聯網創新實踐
- 物聯網頂層設計與關鍵技術
- 現代通信系統(第5版)
- 圖解物聯網
- 信息技術安全評估準則:源流、方法與實踐
- 工業以太網技術:AFDX/TTE網絡原理、接口、互連與安全
- Intelligent Mobile Projects with TensorFlow
- 算力網絡:云網融合2.0時代的網絡架構與關鍵技術