IOS KVO Overview
The interview is often asked: what is KVO? Since the probability of this problem is so great, let's talk about what is KVO. The next time you have an interviewer to ask you, you can come up with a way to highlight the high-force lattice
Overview
Q: What is KVO?
A: KVO is the abbreviation of Key-value observing. It provides a mechanism for the object to receive notification when the properties of the specified object have been modified. Simply put, the KVO will automatically notify the appropriate observer when the property of the observed object has been modified each time it is specified.
If you can answer this, the interviewer will not say you are wrong, this is the principle of kvo. But if you can say the benefits of KVO, it will certainly win the interviewer's admiration. Like what:
- The most immediate benefit of using KVO is that you can reduce the amount of code.
- KVO is one of the observer design patterns that facilitates decoupling of business logic from view control.
A deeper understanding of KVO, you can write a small demo idea as follows:
- Defines an object people, with the name and age attributes, respectively
- Listen for the Age property of people
- Define a UIButton, in the button's click Method, to change the age of people.
- You'll receive a notification from the age change.
- Removes the notification when the object is destroyed.
The source of this article just online: http://www.superqq.com/blog/2015/06/05/ios-kvogai-shu-yu-shi-jian/
IOS KVO Overview