First Controller:
-(void) Baraction: (uibarbuttonitem*) Sender
{
Nextviewcontroller *next=[[nextviewcontroller Alloc]init];
Upload the value of the current page to the next page
next.stringvalue=self.rv.textfield.text;//Property Passing Value
Block Pass Value
__weak Rootviewcontroller *weakself=self;//weakself can be modified in the block, __week change the state of each other, to avoid release when not released
Block ahead, pass back.
next.pv=^{
return weakSelf.rv.textField.text;
//};
Block Pass Value
next.mb=^ (NSString *str) {
WEAKSELF.RV.TEXTFIELD.TEXT=STR;
};
[Self.navigationcontroller Pushviewcontroller:next Animated:yes];
}
A second controller:
. h file
typedef void (^myblock) (NSString *str);//block value, defines a block
typedef nsstring* (^passvalue) ();//block Front pass back
@interface Nextviewcontroller:uiviewcontroller
Accept the value passed from the previous page
@property (Nonatomic,strong) NSString *stringvalue;//Property Transfer value
Block Pass Value
@property (nonatomic,copy) myblock mb;//block Transfer value
@property (nonatomic,copy) passvalue Pv;//block Front pass behind
. m file
-(void) viewdidload
{
[Super Viewdidload];
Do any additional setup after loading the view.
Uibarbuttonitem *bar=[[uibarbuttonitem alloc]initwithtitle:@ "Back" Style:uibarbuttonitemstyledone target:self action: @selector (baraction:)];
Self.navigationitem.leftbarbuttonitem=bar;
Assign the value passed to the previous page to the current page.
self.nv.textfield.text=self.stringvalue;//Property Passing Value
Self.nv.textfield.text=self.pv;//block, back in front.
}
-(void) Baraction: (uibarbuttonitem*) Sender
{
SELF.MB (self.nv.textField.text);//block Pass Value
[Self.navigationcontroller Popviewcontrolleranimated:yes];
}
IOS Block pass and attribute pass values