1,首先定义代理(定义block)。
2触发代理()触发block,
3,执行代理的对象(执行block的对象)
B界面中的block定义:
(1)typedef void (^CompleteSucessBlock)(NSInteger type);
@interface B : ViewController
(2)@property(copy,nonatomic)CompleteSucessBlock successBlock;
(1)+(2)等同于下者:
//@property(copy,nonatomic)void (^successBlocks) (NSInteger type);
@end
点M文件里面触发block
if (self.successBlock) {
self.successBlock(2);
}
A界面中的block定义:
@interface A : ViewController
@end
@interface A()
B *b = [[B alloc]init];
b.successBlock = ^(NSInteger bb){
[self.navigationController popToViewController:self animated:NO];
C *c= [[C alloc]init];
c.navigationItem.title = @"银行卡";
[self.navigationController pushViewController:c animated:YES];
};
[self.navigationController pushViewController:b animated:YES];