XCode shows errors in example code in Ch. 20

It is most likely that the sample code was written for an earlier version of the Swift. If that is the case, you need to port the sample code to the version of the Swift you are now using.

I don’t have the book, but if you post the sample code I may be able to help you.