Protocols are a type of safety feature used in Swift and other programming languages such as Java, Objective-C, and Go. They could be described as a flavour of subclassing that help provide not only safety but consistency in large code bases. Their purpose is to create a contract or a template, whereby any class or object that adopts the protocol must comply with the contract. The formal swift definition is, 'A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality'. Protocols can be adopted by a class, structure, or enumeration, which then provides an implementation of the protocol. The debugger throws an error if a protocol is adopted but not implemented properly.
In additon to provide safety and consistency the delegation pattern can make code more re-usable. It's premise is that a object can delegate a certain task to another object. This is achieved by passing a reference of each object to each other. For example the delegator will hold an instance variable called, delegate that stores a reference to the delegate. The delegator is often (but not always) instantiated in the delegate's class. So the delegate, will also specify the delegate of the delegator as 'delegator.delegate = self'. Then when the delegator wants to pass of functionality to the delegat in their class they can call methods by writing, delegate?.someFunction. The delegate design pattern is often used alongside protocols, especially when it is likely to be re-used. The protocol can often be written in the delegate. It will state the functions, that the delegate must implement if it is to be delegated certain tasks/functionalities.