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