Creating DrawView

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 Foundation
import 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). ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.