The game screen

Before implementing the game, let's proceed to build the layout of the cards on the table.

The structure

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 ...

Get Swift 2 By Example 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.