Playground sources

Before jumping into the rest of this chapter, you’ll need to learn a new feature of Swift playgrounds: source files.

In Xcode, make sure the Project Navigator is visible by going to View\Navigators

\Show Project Navigator. Under the playground tree you’ll see a slightly dimmed folder named Sources:

On the folder Right-Click\New File and name the file Account.swift. Move the

Account protocol, the BasicAccount class, and the Dollars typealias all to this file.

Create one more source file and name it Checking.swift. Move CheckingAccount

into this file.

That’s it! The important things to note about the Sources folder is that the code within it is treated as a separate module from the code within your playground.

You can comment out the rest of the code in your playground for now. It won’t be able to “see” the code you just moved until later in this chapter.

results matching ""

    No results matching ""