仅有的幸福2017-04-25 09:06:38
The protocol can be understood as what is commonly called an interface. Through the protocol, some design patterns can be implemented in a standardized manner and improve the efficiency of development.
Personally, I feel that many functions of OC exist like patches. Sometimes in order to add an effect, you need to create a new set of grammar rules to use it.
仅有的幸福2017-04-25 09:06:38
The introduction of protocol is quite useful. The simplest one is to implement event delegation (delegate)
In addition, multiple delegates can be implemented but only one class can be inherited
For example, the UITableViewDelegate and UITableViewDataSource owned by TableView in UIKit allow you to easily use a class as the data source of the view without having to inherit a class, which means you can use UIViewController as the data source