The example of this post is: there are two interfaces, A and B. The effect to be achieved is to let A jump to B first, and then there is a color parameter in B. When B jumps to A, pass the color parameter. Give A, use this color in A to change the color of its own interface.
Step 1: In the sender (interface B), make the protocol (declared in the .h header file)
Step 2: Proxy the protocol in the .h file in the sender (interface B). Outgoing classes -- declare proxies.
@interface ConfigViewController : UIViewController
Step 3: Notify the agent in the method in the sender (interface B) ( most important step )
A 1 follow the protocol 2 set the proxy 3 implement the protocol incoming class ---- proxy class
Step 4: Follow the protocol in the receiver (interface A).
@interface ViewController () <ConfigViewControllerDelegate>
Step 5: Set yourself up as a proxy in the receiver (interface A).
ConfigViewController *testVC = [[ConfigViewController alloc] init];
testVC.delegate = self;
Step 6: Implement the methods in the protocol in the receiver (interface A).
- (void)changeBgColor:(UIColor *)color{
self.view.backgroundColor = color;
}