Pass the value on the iOS page (proxy, notification, block, Singleton, and attribute), iosblock

Source: Internet
Author: User

Pass the value on the iOS page (proxy, notification, block, Singleton, and attribute), iosblock
I. Data Transfer Classification

There are two types of page transfer values: Forward transfer and reverse transfer.

Ii. Value Transfer Method

To pass a value, the most basic thing is to pass the value through proxy, notification, block, and so on, as well as attribute values that are frequently used and pass values in a single example,Store the uploaded values.

1. Pass values by proxy

It is simple, clear, and easy to understand. It is also commonly used in actual development.

Delegated tasks:

1.1 declare delegate Variables

1.2 define protocol Methods

1.3 call the delegate Protocol

 

 

What proxy needs to do:

1.1 execute the proxy Protocol

1.2 delegate Method

 

 

2. Notification transfer value

The usage of the notification is very simple. When the notification owner creates a notification and sends the notification, it is OK for the recipient to accept the notification. After the notification is complete, pay attention to removing the notification, too many notices in the eye are not good (zai is a flood of notifications for second-hand Projects)

 

 

In the end, do not forget to remove the notification. It is best to remove the notification in the dealloc method. To avoid unnecessary troubles. The bug can be minimized only when the code is written to the strictest degree. The removal notification generally follows who creates and who removes the removal. In which control is created, it is removed from which controller.

 

 

3. Pass the block Value

3.1 declare the block attribute for passing values

3.2 call block to complete value transfer

 

Recipient: Transmits a block of values to the valuer, and captures the callback value information in the block.

 

4. Attribute Value passing

Attribute Value passing is the most commonly used and will not be used. Basically, you can say goodbye to the IT circle.

 

5. Pass values in a single example

      A singleton is a separate instance, which is equivalent to a common variable that can be used as a public resource throughout the project. A singleton can be divided into a system singleton and a custom Singleton.

6. persistent data value transfer

NSUserDefaults is a type of data persistence mainly used for storage.

 

Conclusion:

If you have any mistakes in this article, please contact me. Ps _ Recent project is not very busy. summarize common knowledge points for future reference and consolidation.

 

 

 

  

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.