1. declare an agent where the data needs to be transmitted outside
@protocol nextviewcontrollerdelegate <nsobject>
2. Declaring Proxy methods
-(void) Didloaddatawithmessage: (nsstring *) message; define or affirm
@end//Correspondence @protocol
general proxy definitions in #import < uikit/uikit.h > to between @interface
3. Defining a property implementation The agent can find this proxy through this property (more difficult to understand)
@property (nonatomic, assign)ID<nextviewcontrollerdelegate>delegate;/ /nextviewcontrollerdelegate for your proxy name
4. Proxies are generally used to transmit values and invoke proxies where they need to be passed
[self. Delegate didloaddatawithmessage:@ "hehehe"];//pass hehehe to the implementation agent
5. Introducing proxies where values are required @interface viewcontroller () <nextviewcontrollerdelegate>
6. Define the variable, hang up the proxy (with the class that declares the proxy, define the object, hang up the agent)
nextviewcontroller *nextview = [[nextviewcontroller alloc]init];
5. Hang Up Agent
NextView. delegate = self;
7. Implement the Proxy method receive the value passed over
-(void) Didloaddatawithmessage: (nsstring *) message{
NSLog(@ "%@", message);
label. Text = message;
}
Finally hope to see this article people more comments, in order to improve, of course, I do not mind everyone concerned about me, we learn together, progress together, thank you!
Definition and use of agents