objective-c - OC 协议为什么诞生以及其存在的意义?
漂亮男人
漂亮男人 2017-04-25 09:04:38
0
2
598

如题,找了很久,没有找到我想要的答案,oc大神能回答下吗?

漂亮男人
漂亮男人

reply all(2)
仅有的幸福

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.

仅有的幸福

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

To put it more broadly, interface-oriented programming can decouple object events. Objects rely on interfaces rather than the specific implementation of objects. This is very powerful for team development and code maintenance.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template