Before implementing the game, let's proceed to build the layout of the cards on the table.
Now let's implement a new class called MemoryViewController
, which extends the UIVewController
class. This will be used to manage the actual view where the Memory Game will be played. The first thing we do is add the class life cycle functions:
class MemoryViewController: UIViewController { private let difficulty: Difficulty init(difficulty: Difficulty) { self.difficulty = difficulty super.init(nibName: nil, bundle: nil) } required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } deinit{ print("deinit") } override func viewDidLoad() { super.viewDidLoad() setup() } } // MARK: Setup private extension MemoryViewController { func setup() { view.backgroundColor = .greenSea() } }
Besides the initializer that accepts the chosen difficulty, although...