1
2
3
4
5
6
7
8
9
|
typedef
void
(^ReturnTextBlock)(NSString *showText);
@interface TextFieldViewController : UIViewController
@property (nonatomic, copy) ReturnTextBlock returnTextBlock;
- (
void
)returnText:(ReturnTextBlock)block;
@end
|
1
|
ReturnTextBlock
|
1
2
3
4
5
6
7
8
9
|
- (
void
)returnText:(ReturnTextBlock)block {
self.returnTextBlock = block;
}
- (
void
)viewWillDisappear:(
BOOL
)animated {
if
(self.returnTextBlock != nil) {
self.returnTextBlock(self.inputTF.text);
}
}
|
1
|
- (
void
)viewWillDisappear:(
BOOL
)animated;
|
1
2
3
4
5
6
7
8
9
10
|
- (
void
)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
TextFieldViewController *tfVC = segue.destinationViewController;
[tfVC returnText:^(NSString *showText) {
self.showLabel.text = showText;
}];
}
|