block定义
int (^addBlock)(int a,int b) = ^(int a,int b){
return a+b;
};
typedef常用block
typedef int (^SomeBlock)(BOOL flag,int value);
SomeBlock block = ^(BOOL flag,int value){
};
常用
//用来在块内修改变量
__block NSInteger count = 0;
//用来避免出现循环引用
__weak typeof (self) weakSelf = self;
//用来加强一下引用,避免weakSelf被释放掉
__strong typeof (self) strongSelf = weakSelf;
网友评论