10.10 Summary
In this chapter, we covered one of the major pillars of object-oriented Swift.
Protocols act as standardized blueprints for classes, structs, and enums, in which their behavior can be standardized. In return, the client code only needs to know about the components of the protocol, not the implementation details of the underlying object—just like your computer knowing about the USB protocol but not about the technicalities of the connected keyboard.
As part of their standards, protocols can impose function, initializer, and property requirements. Data types conforming to the protocol must implement all these requirements, ensuring a smooth connection to the client code.
Protocols can be used as function parameters in the scope ...
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