- Learn Swift by Building Applications
- Emil Atanasov
- 190字
- 2021-06-25 22:13:51
How to add auxiliary code to a playground
Each playground may need a bunch of classes which are helping to illustrate the problem or a solution. There is a handy way to add a chunk of code, which is compiled once it is added or changed. This means that those parts won't be compiled each time the playground is executed. The files containing code are called auxiliary files. To add such a file, we should do the following:
- Open the Navigator panel (cmd + 1).
- Select the Sources folder.
- Press the + button at the bottom of the Navigator panel.
- Select New File.
- Give the new file a nice name related to its role.
- Add the code which you want to reuse in the playground. Don't forget to add the public scope modifier to make it visible in your playground
- Try to use it in the main playground:

Playgrounds can contain different resources such as images, statistic data, sound, and so on. These are placed in the Resources folder. Here is a step-by-step guide on how to add a resource (image/asset) to a playground.
推薦閱讀
- Java完全自學教程
- 趣學Python算法100例
- x86匯編語言:從實模式到保護模式(第2版)
- SAS數據統計分析與編程實踐
- 零基礎學Java程序設計
- Hands-On Enterprise Automation with Python.
- Create React App 2 Quick Start Guide
- Python機器學習之金融風險管理
- Raspberry Pi Robotic Blueprints
- Cocos2d-x Game Development Blueprints
- PHP 8從入門到精通(視頻教學版)
- Python硬件編程實戰
- 計算機組裝與維護(第二版)
- Clojure編程樂趣
- Android從入門到精通