Chapter 18
Using Protocols to Provide Templates for Functionality
In This Chapter
Working with protocols
Conforming classes, structures, and enumerations to a protocol
Using protocols with a UITableViewController
In earlier chapters, when the subject of protocols came up, I promised to talk more about them later. This chapter, then, is the “later” I was referring to. It provides a formal description of protocols and delegates (the implementers of protocols) along with examples of their use — including perhaps the most common use of protocols and delegates you may encounter: table views with their data sources and delegate protocols.
You can find more details about protocols in the Swift documentation on developer.apple.com. Protocols can be used to implement complex architectures, but in and of themselves, they’re quite simple, as you’ll see in this chapter.
Understanding Protocols
Protocols declare a set of methods and properties (as well as a few other syntax elements such as ...
Get Swift For Dummies 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.