In addition to a custom struct, TouchTracker needs a custom view.
Create a new Swift file named DrawView. In DrawView.swift, define the DrawView class. Add two properties: an optional Line to keep track of a line that is possibly being drawn and an array of Lines to keep track of lines that have been drawn.
import Foundationimport UIKit class DrawView: UIView { var currentLine: Line? var finishedLines = [Line]() }
An instance of DrawView will be the view of the application’s rootViewController, the default ViewController included in the project. The view controller needs to know that its view will be an instance of DrawView.
Open Main.storyboard. Select the View and open the identity inspector (Command-Option-3). Under Custom Class, change the Class to DrawView (Figure 18.4).