#import// block格式: 返回值(^block名字)(参数)
// (1)定义block
typedef void(^myBlcok)(NSArray *array);
@interface ZQResignVC : UIViewController
// (2)申明block属性
@property (strong, nonatomic) myBlcok block;
@end
// 用block存储值
@implementation ZQResignVC
NSArray *array=[[NSArray alloc]initWithObjects:_userNameText.text,_passWordText.text ,nil];
if (self.block)
{
self.block(array);
}
// 拿到block的值
ZQResignVC *resignVC=[[ZQResignVC alloc]init];
//直接
resignVC.block=^(NSArray *array){
_userNameText.text=array[0];
_passWordText.text=array[1];
};
网友评论