Notice
Notification needs to have a notification center:nsnotificationcenter, custom notifications need to give a name, and then listen.
Pros:
Disadvantages: More Key-value observations (KVO) require more code, and the listener must be removed before it is erased.
Agreement
Using Setdelegate to set proxy objects, the most typical example is the common TableView.
Advantages: the classes that support it have detailed and specific information.
Disadvantages: the class must support delegates. There can be only one delegate connected to an object at a time.
Advantages of KVO:
When there is a property change, KVO will provide an automatic message notification. Developers do not need to implement such a scenario themselves: send a message notification each time the property changes.
This is the greatest advantage provided by the KVO mechanism. Since the scheme has been clearly defined, it can be easily adopted with framework-level support.
Developers do not need to add any code, they do not need to design their own observer model, directly can be used in the project.
Second, the KVO architecture is so powerful that it's easy to support multiple observers observing the same property, as well as related values.
The realization analysis of KVC
KVC used a isa-swizzling technique.
Isa-swizzling is the type-mixed pointer mechanism. KVC mainly through the isa-swizzling, to achieve its internal search and positioning.
The ISA pointer, which is the meaning of the is a kind of, points to the class that maintains the sub-published object. This sub-publication actually contains pointers and other data that point to the methods in the implementation class.
Http://www.isaced.com/post-201.html
http://blog.csdn.net/ajrm0925/article/details/7416419
This article is from the "11204872" blog, please be sure to keep this source http://11214872.blog.51cto.com/11204872/1754492
The difference between IOS agent and notification, KVC and KVO