The second view declares a block attribute:
@ Property (nonatomic, copy) void (^ dotransfermsg) (nsstring * _ MSG );
Then, check whether the block exists in the value passing method.
-(Ibaction) transfertext :( uibutton *) sender {
If (_ dotransfermsg ){
_ Dotransfermsg (@ "Hello there ");
_ Dotransfermsg = nil;
}
[Self. navigationcontroller popviewcontrolleranimated: Yes];
}
In the main view, this block is implemented by the way when the second view is created.
-(Ibaction) loaddetailview :( uibutton *) sender {
[Ibtextlabel settext: Nil];
Detailviewcontroller * _ curdetail = [[detailviewcontroller alloc] initwithnibname: @ "detailviewcontroller"
Bundle: Nil];
[_ Curdetail setdotransfermsg: ^ (nsstring * _ MSG ){
Dispatch_async (dispatch_get_main_queue (), ^ {
[Ibtextlabel settext: _ MSG];
});
}];
[Self. navigationcontroller pushviewcontroller: _ curdetail
Animated: Yes];
[_ Curdetail release];
}
That's all