"iOS Development-data transfer" About two controller jump data transfer

Source: Internet
Author: User

Forward delivery

When a controller switches to the next control, this time the data is passed forward, so only need to jump before the execution of a method on the line.

/*就是执行控制器跳转之间的那条线之前做的方法*/- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{    // 1.取得目标控制器    UIViewController *contactVc = segue.destinationViewController;    // 2.设置标题    contactVc.title = [NSString stringWithFormat:@"%@的联系人列表"self.accountField.text];}
Reverse Delivery

When a controller needs to switch to his last controller, it needs to use proxy mode when passing data to the previous controller.

Suppose control B is going to transfer the data to the previous controller A

A proxy agreement is declared in B

@protocol MJEditViewControllerDelegate <NSObject>@optional//A要执行的方法,B会把数据传递给设个方法,A实现这个方法设置自己的数据,@end

A adhere to this protocol, then implement the method in the protocol, then set its agent to a in B

b Get the data ready, then notify his agent A.

 //2. Notification Agent    if([ Self. DelegateRespondstoselector:@selector(Proxy method:)]) {//Update model data         Self. Contact. Name= Self. NameField. Text; Self. Contact. Phone= Self. Phonefield. Text; [ Self. DelegateEditviewcontroller: SelfDidsavecontact: Self. Contact]; }

"iOS Development-data transfer" About two controller jump data transfer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.