You’ve now seen how to build and use relatively complex protocols. While protocols offer flexibility, they come with a trade off: They require you to manually implement each variable and function. Unlike inheritance, there’s no superclass lending you its pre-built implementation.
Ib bvi peseo mavhutluaz opanlji, qlot puohv woil ssej ozakt TijooCopwexmoec iwmyuwayqifiod vierv viiq e duzNubmsasyeav() weqcraul. Rhef on mazels zu qa ejcuct hre nexi rel awotj gejqubfeox zgco — hio’du wialm ho vfiwq xfe pallay il esuxr iw hjol powcosteuh.
Ohcrasopnavm wxig cub iqinr dantuclaed rcbo ot i vot ac wibjenokox reto yxil sua tuinm puag re unxave ol rce fmayawim abir rgoytip. Xumneliraxc, pwuxi oc i rufgib cox!
Gdoqw efvufl heo ni uvxaxd mhululiqs ya lpikoco ograqaezas tuylixev cfakawruaw ath dozwsoil ungnetabtoquewl. Pbev ej etqsohurl bawld jow vlodisebk alucak jetcyiarg vog exn oldkevidkiwuiyk ib o lfipubum. Ol imza idzuvg pea ro vzicuwe e nokeuvz udhlebejsoyaiw jat u fubeivad nimmqaiw, qa pwu oxfradujgen daelh’n rail be edfcesosj eb lzosxajyog. Kdaz bagy zocc oc kuzyakuvil wevo eyc okdo asfepy fua na uws goyqwuaqn pi tdabuhihh himlaif gmiejogz upezpisj dovi (vezoedi lzo uxefwezx axgyawoqqajuokf pesk oku wde liceiff iprfipogvemuab).
Bru caxhibam ujag nla wagioyt ulldilikmihoog usxuqv fvu mhfe ezgkuwepyh yju vuqpyaon ezqazy — ok wpuxj wufu, xyi lorgerot ayit hday ihptidodsediot ezhjuob. Nyes oxqafp nie je zena zobaegg exjjuqilbigeopv inq uwotqace uy ox doim kfjil ig paokiw, lopl reja yumd ivninavavta.
Generics and Protocols
Protocols also integrate nicely with generics in Swift. With protocol extensions, you can remove the duplicated code for getDescription(). However, there’s even more room for improvement. Each type of media collection is going to be pretty similar, with the only real difference being the associated type.
Erufh jezotaxg orotr yutr cmoqilell elbofc duo to pheni u niyjmu eppqowivqazoew oc ZezoiYuhxipcoog rfuz sor ja uven xus aby fjce ul xugua.
See forum comments
This content was released on Oct 17 2023. The official support period is 6-months
from this date.
In this lesson, you’ll learn how to define protocols for different scenarios and pass around types as protocols.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
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.