All about protocols in swift

Protocol oriented programming , like functional programming is an important concept in swift . I am learning protocols in swift and I am documenting it here. Everything I know about protocols will be here in this article. Do read and update your knowledge.

Abhimuralidharan
11 min readJul 29, 2017

Source : Apple Docs

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.

So, keeping it simple, a protocol says a struct , class or enum that if you want to be THAT, do THIS, this and THis. Example: if you want to be a human, you have to EAT, SLEEP, and Take REST and repeat!!! 🤓.

Protocol Syntax

Classes , structs, enums can adopt these protocol by placing protocol’s name after the type’s name, separated by a colon, as part of…

--

--

Abhimuralidharan
Abhimuralidharan

Written by Abhimuralidharan

iOS and tvOS developer, dreamer, photographer 🤨

Responses (16)