//声明块
返回类型 (^块名称)(参数列表)
void (^blockA)(void) = 0;
//定义块
void (^blockB)(int) = ^(int b){
NSLog(@"block B, b=%d", b);
};
//用参数块实现回调
+(void) blockParam:(int)a b:(int(^)(int))b{
NSLog(@"a = %d", a);
if (b) {
NSLog(@"call b block");
b(100);
}
}
+(void) test{
[self blockParam:99 b:^(int p){
NSLog(@"this is b:%d", p);
return p;
}];
}