#import <UIKit/UIKit.h>
@interface Firstviewcontroller:uiviewcontroller
@property (Weak, nonatomic) Iboutlet Uitextfield *contenttxtfield;
@end
#import "SecondViewController.h"
#import "FirstViewController.h"
@interface Firstviewcontroller ()
@end
@implementation Firstviewcontroller
-(void) viewdidload
{
[Super Viewdidload];
Additional setup after loading the view, typically from a nib.
}
-(void) didreceivememorywarning
{
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
-(Ibaction) Jumptosecondbtnclick: (UIButton *) sender
{
Uistoryboard *firstsb=[uistoryboard storyboardwithname:@ "Main" bundle:nil];
Secondviewcontroller *secondctl=[firstsb instantiateviewcontrollerwithidentifier:@ "Second"];
[Secondctl compeleteblock:^ (NSString *string) {
_contenttxtfield.text=string;
}];
[Self.navigationcontroller Pushviewcontroller:secondctl Animated:yes];
}
@end
#import <UIKit/UIKit.h>
typedef void (^blockpassvalue) (NSString *string);
@interface Secondviewcontroller:uiviewcontroller
{
Blockpassvalue Myblockvalue;
}
@property (Weak, nonatomic) Iboutlet Uitextfield *valuetxtfield;
-(void) Compeleteblock: (Blockpassvalue) Myblock;
@end
#import "SecondViewController.h"
@interface Secondviewcontroller ()
@end
@implementation Secondviewcontroller
-(void) viewdidload
{
[Super Viewdidload];
Do any additional setup after loading the view.
}
-(void) didreceivememorywarning
{
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
-(void) Compeleteblock: (blockpassvalue) Myblock
{
Myblockvalue=myblock;
}
-(Ibaction) Backtofirstbtnclick: (UIButton *) sender
{
if (Myblockvalue)
{
Myblockvalue (_valuetxtfield.text);
}
[Self.navigationcontroller Popviewcontrolleranimated:yes];
}
@end
IOS block to transfer values between pages