Summary of IOS value-transfer methods

Source: Internet
Author: User

1. Attribute Passing value
The value is passed back to the front.

2. Protocol Transmission value

http://liuyafang.blog.51cto.com/8837978/1549391


3, block transfer value
Instead of the protocol proxy value, the main point in time.

http://liuyafang.blog.51cto.com/8837978/1551399

4, simple interest transmission value
Data sharing.
5. Notification value

http://liuyafang.blog.51cto.com/8837978/1557029

Notification Center
The Nsnotificationcenter provides a more decoupled approach. The most typical application is any object pair that can send notifications to the center, while any object can listen to the notification of the center.
The code to send the notification is as follows:

[[nsnotificationcenter defaultcenter]       postnotificationname:@ "Mynotificationname"     object:broadcasterObject]; The code for the
register to receive notifications is as follows:

[[Nsnotificationcenter Defaultcenter] Addobserver:listenerobject selector: @selector (receivingmethodonlistener:) name:@ "Mynotificationname" object:nil];
You can specify a specific broadcaster object when registering for a notification, but this is not required. You may have noticed the defaultcenter. This is actually the only center you'll use in your app. Notifications are open to the entire application, so there is only one center.
There is also a nsdistributednotificationcenter. This is used for inter-application communication. There is only one center of that type on the entire computer.
Pros: Both the sender and the recipient of the notification do not need to know each other. You can specify the specific method to receive notifications. The notification name can be any string.
Disadvantage: More code is required to observe the key value. You must remove listeners before deleting them. You cannot pass a large number of values, only let who do what.


This article is from "Xiao Liu _blog" blog, please be sure to keep this source http://liuyafang.blog.51cto.com/8837978/1557031

Summary of IOS value-passing methods

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.