iOS block
定义:
returnType (^funcName)(paramType paraName) = ^(paramType paraName){};
作为方法参数时:
- (void)fun:( returnType (^funcName)(paramType paraName) ) blockName{}
typedef:
typedef returnType (^funcName)(paramType paraName);
防止block发生循环引用:
__weak __typeof(self) weakSelf = self;
AController *vc = [[AController alloc] initWithCallback:^{
[weakSelf.button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
}];
Stay hungry,stay foolish.