iOS delegate, the popular point is that the value of the page between the transfer.
There are three ways to sum up the value of the iOS page you know now
1. Send a value for notifications using Nsnotification
The main is to send a notification through the nsnotificationcenter, he does not know to pass the value to who, when listens the page receives the notification message, only then obtains the message.
2. Is the use of the property to pass the value, I mainly use the a->b a page to jump to the B page, you will need a in B to pass the Preparfrosegue method from A to B
3. By Nsuserdefault, the main idea is to write the value to a localized file, when another page needs to go back to this file by URL
4. Through the delegate to transmit the value, as long as the A->b page jump, when the operation in B after the completion of the operation in B to the data on a page display, this time to use the delegate
First of all: we need to declare a delegate in B
The code in B.h is as follows
@protocol hbaddpersontableviewcontrollerdelegate; @interface Hbaddpersontableviewcontroller:uitableviewcontroller@property (nonatomic, Strong) ID Delegate ; @end @protocol Hbaddpersontableviewcontrollerdelegate <nsobject>-(void) Savepayerorconsumer: (Nsarray *) Usersinfo Istocunsumer: (bool) Istoconsume Istopayer: (bool) Istopayer; @end
The code in B.M is as follows
-(Ibaction) Completebuttonclick: (ID) sender{if(self. Delegate) {[Self. Delegate savepayerorconsumer:_selectcontact Istocunsumer:_iscomefromgetconsumer istopayer:_iscomefromgetpayer];}}
Where a page is to declare this delegate, and in the. m file to implement the declared method, the value of the parameter is a number in B
Transfer values between IOS pages (presenter delegate)