In the preceding example, and for most of this book, we focused on iOS-based playgrounds, but macOS-based playgrounds are just as useful for the macOS platform and can also be used for UI testing and experimentation.
In the GitHub repository for this chapter, you will find a macOS-based playground called Simple_macOS.playground that also creates a simple bar chart view, at http://swiftbook.link/code/chapter6.
Alternatively, you can create a new macOS-based playground and enter the following code:
import PlaygroundSupportimport Cocoastruct Color { let red: CGFloat let green: CGFloat let blue: CGFloat let alpha: CGFloat = 1.0 var displayColor: NSColor { return NSColor(calibratedRed: red, green: green, blue: blue, alpha: alpha ...