The second view declares a block property:
@property (nonatomic, copy) void(^doTransferMsg)(NSString *_msg);
Then check whether the block exists in the value transfer method
- (IBAction)transferText:(UIButton *)sender {
if (_doTransferMsg) {
_doTransferMsg(@"hello there" );
_doTransferMsg = nil;
}
[self.navigationController popViewControllerAnimated:YES];
}
In the main View, when creating the second view, By the way, implement this block
- (IBAction)LoadDetailView:(UIButton *)sender {
[ibTextLabel setText:nil];
DetailViewController *_curDetail = [[DetailViewController alloc] initWithNibName:@ "DetailViewController"
*_msg) {
dispatch_async(dispatch_get_main_queue(), ^{
[ibTextLabel setText:_msg];
} );
}];
[self.navigationController pushViewController:_curDetail
🎜>
that's all