Quick look is a good tool that helps us to visualize the current status of an object, but sometimes when we create our own class with its own logic, quick look won't be able to draw something that represents the object without your help.
In this recipe, we will learn how to create our own class representation. To do this, we will create a class that represents a checker board.
Create a new playground called Chapter 6 Checkers
with the iOS option selected. If you select MacOS, remember that you should import Cocoa and replace some types with the equivalent one, such as NSBezierPath
instead of UIBezierPath
.
Let's create our checkerboard that makes dangerous moves:
Let's start creating a class that inherits from
NSObject
:class CheckersBoard:NSObject {
Before we go any further, we need to define the status of each square, as you know it could have a black piece, a white piece, or it could be empty:
enum BoardSpace { case FREE, WHITE,...