Delegation pattern in Swift 5.1
What is the Protocol?

A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol.

In addition to specifying requirements that conforming types must implement, you can extend a protocol to implement some of these requirements or to implement additional functionality that conforming types can take advantage of.

The protocol you have seen so many times while development of iOS apps most commonly in UITableViewDelegate & UITableViewDataSource. Both of these protocols have their optional and required methods.

In this article we will go through some basics about delegation protocol in Swift and show you how to implement both optional and required protocol methods.
[]
['Delegation', 'Code', 'iOS', 'Development', 'Swift']