SecondViewController.h
#warning第一步:聲明協(xié)議方法
@protocolpassValueDelegate
-(void)passContent:(NSString*)content;
@end
SecondViewController.h
#warning第二步:聲明代理人屬性
@property(nonatomic,assign)iddelegate;
SecondViewController.m
-(void)didClickedButton:(UIButton*)button{
#warning第三步:命令代理人執(zhí)行協(xié)議方法
[self.delegatepassContent:self.textField.text];
[self.navigationControllerpopToRootViewControllerAnimated:YES];
}
RootViewController.m
#warning第四步:前一頁(yè)簽協(xié)議
@interfaceRootViewController()
RootViewController.m
-(void)didClickedButton:(UIButton*)button{
SecondViewController* secVC = [[SecondViewControlleralloc]init];
secVC.passString=self.label.text;
#warning第五步:設(shè)置代理人
secVC.delegate=self;
[self.navigationControllerpushViewController:secVCanimated:YES];
}
RootViewController.m
#warning第六步:實(shí)現(xiàn)協(xié)議方法
-(void)passContent:(NSString*)content{
self.label.text= content;
}