Play with Protocols in Swift-3.0……

Why Protocol is required in Swift ??

* Act as Interface
 * Specifies a set of behaviours which should implement
 * Act as contract that your classes can conform to 
 * Properties Requirement || Method Requirement || Init requirement
 * Used as Delegate
 * Used as Types

How to declare Protocol??

What does Properties Requirement means??

*Protocol conformingType must provide Instance || Type property with particular type && name .
*There is no constraint that properties must be Stored || Computed Type
*Can specifies get || set or both for the properties .

Type Properties:

static keyword is required

What does Method Requirement means??

* Specific instance methods and type methods to be implemented by conforming type.

Mutating Method Requirement ??

Mutating method give permit to change the value of properties of that instance .

Initializer Requirements:

Note : Initilizer can be Failable Initializer

How Protocol is used as Type ??

How Protocol help in Delegation ??

Delegation ? : Design Pattern that enable the struct || class to share the responsibility to another instance .

Protocol Inheritance:

Protocol Composition

How to limit Protocol in class only ??

Optional Protocol Requirements