filmov
tv
What is Protocol & Delegate in Swift

Показать описание
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.
The delegate is a design pattern that allows one object to send a message to another object when a specific event happens.
Difference b/w Delegate & Protocol.
We can say Protocol as a set of rules. That rules can be optional or required like we have to use in the protocol. Delegates are a message-passing technique in objective C and swift. An object has to take care of that message
The delegate is a design pattern that allows one object to send a message to another object when a specific event happens.
Difference b/w Delegate & Protocol.
We can say Protocol as a set of rules. That rules can be optional or required like we have to use in the protocol. Delegates are a message-passing technique in objective C and swift. An object has to take care of that message