Protocols
There are times when we would like to describe the implementations (methods, properties, and other requirements) of a type without actually providing any implementation. For this, we can use protocols. Protocols define a blueprint of methods, properties, and other requirements for a class or a structure. A class or a structure can then provide an implementation that conforms to those requirements. The class or structure that provides the implementation is said to conform to the protocol. Protocols are very important to the Swift language. The entire Swift standard library is based on them, and we will be looking at protocols and how to use them in Chapter 9, Protocols and Protocol Extensions, and Chapter 10, Protocol Oriented Design.
Protocol syntax
The syntax to define a protocol is very similar to how we define a class or a structure. The following example shows the syntax that's used to define a protocol:
protocol MyProtocol {
//protocol definition...