typedef block

给同一种类型的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;
}

 

posted @ 2015-04-07 19:07  嗷大喵  阅读(324)  评论(0编辑  收藏  举报