19 Protocols
In Chapter 16, you learned about using access controls to hide information. Hiding information is a form of encapsulation, which allows you to design your software in such a way that you can change one part without affecting the rest. Swift also supports another form of encapsulation: a protocol, which allows you to specify and work with the interface of a type without knowing the type itself. An interface is a set of properties and methods that a type provides.
Protocols are a more abstract concept than many of the topics you have learned about so far. To get a handle on protocols and how they work, you will create a function that formats data into a table that looks like a simple spreadsheet. Next, you will use ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access