10 Protocols
In Swift, protocols define a common blueprint of classes, structs, or enums. They enable polymorphism and abstractions, allowing for development of interchangeable objects. Protocols are key elements of design patterns and object thinking.
In this chapter, you will learn about protocols in Swift, which enable an enormous degree of flexibility in codebases by providing blueprints for classes, structs, or enums.
In many object-oriented languages, protocols are referred to as interfaces. So if you’re familiar with interfaces in another language, know that Swift calls them protocols. But even for experienced programmers, this chapter is worth going through. Swift protocols might offer different merits or shortcomings than those of your ...
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