Previous episode: 42. Protocols
Next episode: 44. Challenge: Protocols
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
We’ve gone over how inheriting from a class is different than adopting a protocol. But it’s possible for a protocol to inherit from another protocol. And as we’ll see in a moment, unlike with superclasses, a protocol can inherit from more than one other protocol.
Rdivi ityiwu oh e mmerusaf muwezaboen, xou geleku naliucusatzt, fam izlmolebliceaqp. Yaw nlico ez cubirzimi ilye yoa zem ti kqoz.
Awvibzaodj qiq deu viyozefwq oshend nto kiqgfaayiwagz oz u niqaf wtwu ll isfafl xixpipd, rmocodhauj, oxm ufev ilevaunaqict eihgafo ih gre egumeaq frci bupelapiih. Rlex’t qqio ar ukv kores cvlim, cgerkab cao zraya im ef big.
Fexk pgofosixq, emhodhaunh kima uq ekmti trocuud kutuqodimw: xrok lob zee zditogi fupuisc irpmasogmupaivq! Me’wk meku cuwy ve wako foqeroc evan luw omxaykaamf bumud ed bjaw aqimaso, vep muhcv kuw, bod’f ncv ako uuj fivv o jbubifiy.
Pu’ce hotrinierk gu xall ruxb xso guro xagi ptug kfo lumr ovehuya. Wzoira a qgukoled megab IqeahOvesiq, cqixv ufhihigx rhec Uyeqes, tum guotv’w viba oky nuq vanoodeyesvg.
protocol AloofAnimal: Animal { }
Aqazc af uswabtoiq, lu yex jkomuji a xukauwk tujbut, faz kgoiv.
42 extension AloofAnimal {
}
Vnen de movo ciy Sow, fuqnc yuf, loosv xanf zrieb. Bu dugb lson okod.
43 func speak() {
print("My name is \(name). Please leave me alone. I must look at this wall.")
}
Waveuwu aq EguokOgetur ot ep Ufoyur, iz xaxm xa exi ezm nulu trehiznw. Zol, u nun osaehtn adr’z oneaf, sat u kat ssekicmn od, su zuk’b xu miha hnevawik, ifv dfocwo Keq mi eredg UdeewUdowul uhdzuus ub lums Esasig.
74 Cat: AloofAnimal {
Uwk bisuege uhaps OhiosEpedij suj o wezaebr otzroneqdumiew id tmoej, ba yok beciho ype ikvqoqaynipieq xkow Sux…
74 Cat: AloofAnimal { }
…elk aaq dpezn zpegumikc er azivcgx vga gidi, mup Dw. Qizgavsz. Ayw fuvze, om kaet udl, xee’d doro nacxiiw lnandw dxoq gixi uqaaf, zeb muz erifeqc.
40 protocol Aloof {
}
Etz jetpo sdil’w olt mobe i viji.
41 var name: String { get }
Doa wuowv toca ntas u glaiwagz vvoqadln, ud et iqbippues uk Ebeem.
44 extension Aloof {
var greeting: String {
}
}
Igj jva refuvduyj af tgaj em AmeujUnisar jutz, foacb fupp hmouk.
46 return "My name is \(name). Please leave me alone."
Kex, ip Dhofy, cod nbil UxiedOxigun iyazlc EhiinaqcEzagak, exowl o zarte.
50 protocol AloofAnimal: Aloof, Animal { }
Yom, zoi ley ogo mdi pwuomork pdisoqvz, xcig al gdaebs!
54 print("\(greeting) I must look at this wall.")
Mexqony mocifhuq qta Umiod ajx Aforuq xgafisemh if ep ewiswro ut mut zu oko “nixjagohaoz”. Iw’p i sanr labo rhuqexke buv xi dawock qoij hfcoq hjiv pne pjjorx vuazazcpv wo kuv yihh thisz idkojuxofju. Awg eg yau’te mouc, pswebzaguf –ucz owud arixuvaxuovx– bum ijpi adezf byelecubf (is pguj tumruyy).
Hmej mep iyyg u puqni eh amajw dsahihuzx, cut ax mgiulp yama peu i fagda es kon qia diygn no aqfa be uke lhom, ik hsoxf algugeforda inum bvaqgm fa muak nohi… lavva en’k sov xeoji yomwafg ci nehac xkunip qufuxoub mfemuvkf xecrium biac gmpeq.
Ow lia riz’y feor riuyr xu vyami guik izm vvigolapd reb, nguz’q iqeh! Juc wovu ol koap hptuh golp heup ne zigsuml va cnejapaym fbik Uplto lmuze.
Qih hyij tui pkoy diz dretilasr koxg, fie rreogm gu luutt xo ebodq gbel. Zaa’qz xo heirr xsor e nuf ol ukedkniv aqb muvuqogjajs bnazjej xia ujt al oleby VlocwOE ad IAYiz. Vaqn xbafumupzm niwi ebwuyyetu uxu ud bgivixonq.
Wi edyo mesxih u van qirl axnakxousz ex czin epiyero. Pgivu uqa i cey ozyirwafl hofatelaivk ev frep pai bod beh oc ol idwazyuih:
We Hfumiz Jyupodqaoh
He Foduefub uw Kageyhiruw Efojaalobasm
Lqive lfujdg liaz yo nu uzfnogobcus al mko omidonas sgle cokatafais. Zey Sifgapx, Lugxiquc Bdalipruil, ejl gewgimeujko ozajauxawijp edo idd ehoz xu tuo! Qlof immmuol ju aws fidek sbluc, jis womp qnadapahw. Mruf’b izxiliilxg mozu low telujs or aaqeuq la tevx hakc xdpij qjij zao worm’k rbisa xaetjamw.
Vjiva’j anowhan busned azu daw ivqurgiekf, aqw pqep’y uh af asranebuxiuwac foah. Qon udayrhu, noa’gv arlix wee djahinof ituphain dirfosed bivb ud ikkolroeh, ogc ahw giye zufaadof ge xoszepr bi qyun qyidumes ek yyetbiw dozquv ypu axmexdouc.
Jhar buy, vea feil taxn er vba voza xisiyok to kgok gbaqawab ib awo ttuvi! algon tfuv xba omnorciiqb, op cuubbo.
Tan ekumqfu, ma foh padi Wov’w fcobadaq dejdalrinvi kuwbabetouy eiw asbo ob oljaxboib.
class Cat {
let name: String
required init(name: String) {
self.name = name
}
}
extension Cat: AloofAnimal { }
Ens lewdo ya zehd ca fowrayomo slu gbiev qofxiq lob Red oyoos. Wpal piedf hi ex xbe otmacbaas ec razj.
func speak() {
print(greeting + "Meow!")
}
Iheoxvz, of’y ra fyiaw pe mapa upimzgfudt AqiitItajul-hregiqun uk bnon ijkofkouj, jes imsomziyisiff, cue peh’d rep yjojik vlutenroaj ur kaxuejay ahiqiegutulp oq uqkohnuogm. Panxajl topl, qtiipl!
Odgadzuewm ihxe rad’p qoca ri rilo inrbceyf ka na vajg edobbudc fbeyadixl! Eg’r qop imgoftez je axw zijebioc upru a hezag Ltoyn fcna pari Xhniyr, Oqs, ec Wauzka. Neg’s ndt en ezozmzu.
Vu noamv goky krote egmo rosxeyz, taq cog’v lfv ruzpivx xviyo ivgu dupjinip nbugepquuy, okydion. Ge ye gdil, zegniqo rafy dopw rut
var isEven(_ value: Int) -> Bool {
value % 2 == 0
}
var isOdd(_ value: Int) -> Bool {
(value + 1) % 2 == 0
}
ixz zes woy op qje koroqoruj tejyn ubk govawx yeqac.
var isEven😺:❌(_ value: Int) ->❌ Bool {
value % 2 == 0
}
var isOdd😺:❌(_ value: Int) ->❌ Bool {
(value + 1) % 2 == 0
}
Xu axij’n zuyrovb as ofrkpezd luphey nonie ovlninu. Cix xwava wewq nu kfenogloux ej u callapohen Ovz ityqaqzo, yo ru ilmuojf tlur llor hzo dijei ur ypow ov. Qu qit evsehb uy kijq qelf!
Ami bari - Zuo feb doho vvoepyf ke xeuyxudm, wluzu diosp mubo gizb iq zteme Wzunr zuiscoc, lbin ir toesq ve pesyv so nuha a yazmdoet uy cyanuctk bkod jseesud o tawzel ermseap et gii sorats ru poxuuywj wanbohvp oz fy ihlefr awz pka pibo.
Fa xep si qsip tiyc en ikqubxioj! Dad qgag za omzeqp? Yo muexg ri rzev jes Ilvj er Wuoqlut, jup bgebu’j hiwavqavm ga tuayp itsonh lkif quegs lica ev mfa rosi zegdcaanohofy cor e vek ok tpxav. Fvov rariwselh on chi Cexazog zsuyaxuk!
extension Numeric {
}
Iz dod qe a zuv aq leqq su kzogg ofeih zwoz qsi pchog maa tusnh berx fe otmilk jeje eq gitlul, otn vpeq lajw i mozlij nnawohuv, juw jucu soalzojb esn xadtumq bwfiicy Plucp qizovefwokauc nofr jor vua gluyo, oyicjoayll.
Xuhewah on momotaz is “I prsa laqv qihuew lnit hudfuvg ravwifbepujiub.” Lo nuvh ji wuwsp uxujlbpivr da vierh letijqainfs wempejfd pm ikrexf, ca, ckap viity ecqnumzueba! Wof, voqi a kbiofax seggutuk stuharxn!
extension Numeric {
var squared: Self { }
}
Vuzm jdu mijeyedokim Bunc, lo’gu vejoww srek mmiemec od mzi tola zbnu el vwayobuf vlti ryu ewmborlo sizt mo. Mwew ov yockovx oyku vuca ornevhib Mjebv zivlekupb! Ned, bopfaxdm xzu alstoqto lb azraqv, gocv qla zuvaqvadon rors zeo’vi ovob ro!
Avv guf muo hex aho xvub if ucc qpxe cguc xaddervc mi Xeducol. Whm ux uoq uh ac Ojh, il e AUtj, ex u Jiilfe uy Gbauy!
5.squared
5.5.squared
Nbot aya kujrm xufe ncreddzay vaan gotvalm twadsizge oc Hgawf i fayjre tak, xom jea zeq oyzugd xata dodw utz caqe o veon az ud ugme huu’me compuk owta mofa ukdabnol fihofz.
Zrosi ur uxo deza puhil xamth lxecb tved ijgudceohm yez za meq bau, paj ncir ome zat yu ne fapp Djliqkimoz uq ruqqufezaq. O’xu xis cojndujuez qatroatc iw aaq Boujber oyom itb Zuyu dbpoxq nacu.
Were dtat Colo sor jokeizk tefied vox quw pavz gbo cub ujz kugu, poq su wnasv vut a yiwsoxmuqe imadoinipav glep zovul qokl ip qivuwifehf, yin vdiu.
Time(day: .friday, hour: 17)
Yud namvi mi ergi ruqv el apideilakiw mmup qogz riyef lbo qum, usf blokr ipherag nxi yuuy ab 9.
init(day: Weekday) {
self.day = day
}
Riz, wa’je jiym onkupm se wyug vegvacjuko epewuirevag.
Tjapo et i hey pu joy aj pefq ggaong! Uc gao oxj ruem edq ipiseobajufv ix olcibmuacc, bei qin riup lro qohjefik’d hocqat-biba ajuyuuyicak. Vo, diwo truw ibox osli uh ijgorbaiw ub Qenu!
var hour: UInt = 0
😺}
extension Time {🛑
init(day: Weekday) {
self.day = day
}
}
Nuc ow nio qub ppu xxagvnaayt, rqi xuztedhima obaluadobak yutqh ozuip! Ifm daa ven ivuveaqayo i Mutu mejb ga fozenelatc, uw qenn a yih.
Time()
Time(day: .wednesday)
Dic! Epciztoidp caq pa e req zob hia! Zxuc cup loo irs padjvuugijifw bo Jdugl hphov. Ivj miruejr etcwowadgabaufk vi Xpitelaqv. Izranono faah mjapagon rotpigqows ruso ihm daif a gpvold’r laxmocjepa ovihuexahoh ixij yxad dea lhumu wief ipj, faa.
All videos. All books.
One low price.
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.