Chapter 15
Protocols
In the real world, people on official business are often required to follow strict procedures when dealing with certain situations. Law enforcement officials, for example, are required to “follow protocol” when making inquiries or collecting evidence.
In the world of object-oriented programming, it’s important to be able to define a set of behaviors that’s expected of an object in a given situation. As an example, a table view expects to be able to communicate with a data source object in order to find out what it’s required to display. This means the data source must be able to respond to the specific messages the table view might send.
Protocols define the interface—a blueprint of methods, properties, and other requirements ...
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