Transfer of values between controllers

Source: Internet
Author: User

There are 8 ways in which page values are transmitted.

-. Attribute pass value (forward pass value)

Declare a property in AttributeVC.h to receive the value passed in.

In ROOTVIEWVC.M, assign a value

Use this value in ATTRIBUTEVC.M

Two. Proxy pass value ())

First define and declare the proxy in the second page DelegateVC.h,

Why delegate (proxy) properties are assign instead of retain

Circular references
All reference counting systems have problems with cyclic applications. For example, the following reference relationship:
• Object A was created and referenced to object B.
• Object B was created and referenced to object C.
• Object C was created and referenced to object B.
At this time, the reference counts for B and C are 2 and 1, respectively. When a no longer uses B, the call release releases the ownership of B, because C also references B, so the reference count for B is 1,b and will not be freed. B is not released, the reference count of C is 1,c and will not be released. From then on, B and C remain in memory forever.
In this case, the circular reference must be interrupted and the reference relationship maintained through other rules. For example, our common delegate is often a property of the Assign mode rather than the Retain method, and the assignment does not increase the reference count to prevent unnecessary circular references on both sides of the delegation. If a Uitableviewcontroller object a acquires ownership of UITableView object B through retain, the delegate of this UITableView object B is a, and if this delegate is retain mode, There's basically no chance of releasing these two objects. You should also be aware of this when designing your delegate model.
Because the memory leaks generated by circular references are instrument, you should be very careful

Determine the existence of proxy objects in DELEGATEVC.M, bind the corresponding methods

And then in RootViewVC.h.

Specifying the agent in ROOTVIEWVC.M and executing the proxy method

Three. Block pass value (reverse value)

In

In BlockPassValue.h

In the BLOCKPASSVALUE.M

Transfer of values between controllers

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.