篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Swift - 代表和协议相关的知识,希望对你有一定的参考价值。
See: https://makeapppie.com/2016/09/23/why-do-we-need-delegates-in-ios-and-watchos/
See: https://makeapppie.com/2016/06/27/using-segues-and-delegates-for-navigation-controllers-in-swift-3-0/
Delegation uses protocols. Protocols are a set of properties and methods that while declared in one place, another class implements. They allow for a layer of abstraction. A class adopts a protocol to do something. The protocol defines what the something is. The adopting class will have the code how it gets done.