Message transmission mechanism (KVO, Notification, delegation, block, and target-action) in iOS --- reprint, kvotarget-action

Source: Internet
Author: User

Message transmission mechanism (KVO, Notification, delegation, block, and target-action) in iOS --- reprint, kvotarget-action
Note 1: This article is translated from Communication Patterns by the [blog. The Directory of this article is as follows:Available MechanismMake the right choiceFramework example SummaryEach application is more or less composed of loosely coupled objects. to complete tasks well between these objects, message transmission is required. This article will introduce all the available message passing mechanisms, introduce how these mechanisms are used in Apple's Framework through examples, and introduce some best practices and suggestions, tell you when to choose the mechanism to use. Although the topic of this phase is about the Foundation Framework, this article also introduces some messaging mechanisms beyond the scope of the Foundation Framework (KVO and Notification) and delegation, block and target-action. In most cases, it is very clear what mechanism should be used for message passing. Of course, in some cases, there is no clear answer to what mechanism to use. You need to try it yourself. In this article, the receiver [recipient] and the sender [sender] are often mentioned. In the message transmission mechanism, we can use an example to explain how a table view is a sender, and its delegate is the receiver. Core Data managed object context is the sender of the notification, and the receiver obtains the notification. A slider is the sender of the action message, and the responder corresponding to the implementation of this action in the Code is the receiver. If a property in an object supports KVO, then Who modifies the value, who is the sender, and the corresponding observer (observer) is the receiver.Available MechanismFirst, let's look at the specific characteristics of each mechanism. In the next section, I will introduce how to select the correct message transmission mechanism based on a flowchart. Finally, we will introduce some examples from the apple Framework and explain why a fixed mechanism should be selected under certain conditions.KVOKVO provides a mechanism to notify the observer of a property value in an object when it changes. The implementation of KVO is included in the Foundation. Many frameworks built based on the Foundation depend on KVO. To understand

Related Article

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.