iOS delegate transfer value

Source: Internet
Author: User

The iOS delegate-to-value approach plays an important role in development, and it may be difficult for beginners to figure out

Bo Master is also through the constant search for information, in the development of slowly learned!

First of all we assume that there is a A, a, a two controller, a controller has a TextField and a BUTTON,B controller has a label

When we click on the button in a, we have to pass the text value inside the TextField to the label in B.

In A.h we do write the following code:

In the button click event in the a.m. we write the following code:

Import the A.h file in B.h and follow the Passvaluedelegate protocol and implement the Methods in the protocol:

This completes the way that a delegate is passed the value

The focus of this example is to demonstrate the value of the delegate, the basic control is not affixed to the code!

Combining the above code we are not difficult to find:

The tasks to be commissioned are:

1. Define the protocol and publicly declare a delegate variable

2. Set the proxy delegate object, call the pass-through method through the delegate variable

The work that the agent needs to do is:

1. Follow the agreement and implement its delegation method

iOS delegate transfer value

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.