给同一种类型的block定义一个别名
typedef int (^MyBlock) (int , int); int main(int argc, const char * argv[]) {
@autoreleasepool {
MyBlock sumBlock = ^(int a , int b){
return a + b;
}; int i = sumBlock(2,3);
NSLog(@"%d",i); MyBlock avgBlock = ^(int a , int b){
return (a + b) / 2;
};
int k = avgBlock(10,30);
NSLog(@"%d",k);
}
return 0;
}