The block interface implements value passing and the block interface implements
In the. h file of second
First, define a BLOCK to return an empty type. The parameter is the type you want to transmit. Here it is NSString.
Typedefvoid (^ LJFBlock) (NSString * str );
Then declare an LJFBlock type test attribute (used for passing parameters on the next interface)
@ Property (nonatomic, copy) LJFBlock block;
Then in the. m file of second
The self. secondTextField. text to be passed in through self. ljfblock.
-(IBAction) backBtnClick :( id) sender {
Self. ljfblock (self. secondTextField. text );
[Self. navigationControllerpopToRootViewControllerAnimated: YES];
}
In the First. m file
-(IBAction) FirstBtnClick :( id) sender {
SecondViewController * second = [[SecondViewControlleralloc] initWithNibName: @ "SecondViewController" bundle: nil];
Second. ljfblock = ^ (NSString * Str ){
Self. firstTextField. text = Str;
};
[Self. navigationControllerpushViewController: second animated: YES];
}
As shown in