IOS KVO Overview

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.