1. Declare the Block property in the. h file of the second view controller:
Define Block@property (nonatomic, copy) void (^nextviewcontrollerblock) (NSString *tftext); @interface Nextviewcontroller () @property (weak, nonatomic) Iboutlet Uitextfield *inputtf; @end-(Ibaction) Btnaction: (ID) Sender {//Determine if block is empty if (self). Nextviewcontrollerblock) {self. Nextviewcontrollerblock (Self.inputTF.text);} [Self.navigationcontroller Popviewcontrolleranimated:yes];} 2. Get the second view controller in the first view and invoke the defined properties with the second view controller: @interface Aviewcontroller () @property (weak, nonatomic) Iboutlet UILabel * Nextvcinfolabel; @end
-(Ibaction) btnclicked: (ID) Sender {
NEXTVIEWCONTROLLER*NEXTVC = [[Nextviewcontroller alloc]init]; nextvc.nextviewcontrollerblock= ^ (NSString *tfText ) {
self.nextVCInfoLabel.text = Tftext;
};
[Self.navigationcontroller PUSHVIEWCONTROLLER:NEXTVC animated:yes];
}
IOS Block Interface Reverse Value small Demo