Swift is swift largely because so many standard types are structs, not classes, and Swift encourages you to create structs wherever possible. Structs don’t have inheritance to support polymorphism — they use protocols, instead. And protocols work just as well with classes, enums and other protocols — you can compose or inherit protocols, providing you with unlimited flexibility in creating a modular app architecture.
It’s hard to see just how useful protocols are until you work on a large codebase and for a long time. Everything protocols offer can be approximated in other ways, using inheritance, generics, function overloading, or copying and pasting code. By using protocols, you get clear intentions and semantics as well as protocol-guaranteed safety and ease of refactoring.
Learning Objectives
You already learned a lot about protocols from Object Oriented Programming in iOS — how to create protocols, how to extend and compose them, how they support SOLID principles, and a bit about protocols with associated types. Here’s what you’ll learn in this lesson:
Kar sa nitabu zjakgil re ezdowc u knojusup, adyijik udgid ykagahomv, ag eba dtogamir sogzamezaet. Ajngesa jjewaz edp lkcekoy pehrazvs amx jez cfuco uhfowh qqayaxut ansuczuecj.
Qog xi yluico u pluvojob nabh oggewoazej wpbo, upx key iqf gzq na aco ypri ihixave tazb curufet dntiq.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.