ViewController.swift in Chapter 1's start project

ViewController is declared like following in ViewController.swift in Chapter 1’s start project
class ViewController: UIViewController, UITextFieldDelegate {

If reader carries on own project from chapter 1’s start project, reader will meet the problem in Chapter 9.

page 145 in Chapter 9.

extension ViewController: UITextFieldDelegate

is not working.

Chapter 9’s start project has no problem. only chapter 1’s start project has a problem.

@hssong Thanks very much for your question, and my apologies for the delayed response.

I do see your point. It should be one or the other, but not both. The use of


is used for better code clarity, and to separate methods belonging to particular Protocols. My guess is that the first approach was used to first setup the project and introduce the reader to the Protocol, and then later as the project developed, the class was refactored slightly for better clarity. I don’t necessarily believe this is an “error” per se, however, I do agree that this can be confusing to the reader if at least clarity is not provided as to why the approach or structure has changed. I do apologize for this oversight :slight_smile:

As a courtesy, here is a link to the updated book if you haven’t downloaded it already!

All the best!