iOS design mode-block implementation of proxy logic

Source: Internet
Author: User

On the A page, click Jump to B page, b page finished, go back to a page, and refresh the content of a page. A typical example is in a list, click Add, jump to the new page, add up, send the data back to the list page, and refresh the contents of the list page.

This, I usually through the agent to achieve, the following try to achieve through the block.

block is defined on page b for Call to a page .

1 /* * 2 *  Confirm Order selection return block3  */ 4 void (^ selectedaddressblock) (Hgaddressmodel * address);

b page, operation completed, to block callback value

1 /**2 * Select the line, in order to confirm the order, choose the delivery address to use3  */4- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath5 {6Hgaddressmodel *entity =Self.datasource[indexpath.row];7     if(self.selectedaddressblock) {8 Self.selectedaddressblock (entity);9     }Ten [Self.navigationcontroller Popviewcontrolleranimated:yes]; One}

A page operation is very simple, jump to the B page, directly call the Block B page we can get the results.

1- (void) Jumpaddress: (UIButton *) Sender {2Addresslistviewcontroller *address =[[Addresslistviewcontroller alloc] init];3address.hidesbottombarwhenpushed =YES;4Address.title =@"Address Management";5Address.selectedaddressblock = ^ (Hgaddressmodel *model) {6Dr_nslog (@"----------model------------%@", model.province_name);7     };8 [Self.navigationcontroller pushviewcontroller:address animated:yes];9}

OK, Finish.

iOS design mode-block implementation of proxy logic

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.