码迷,mamicode.com
首页 > 其他好文 > 详细

block

时间:2015-03-15 22:35:59      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

#import <Foundation/Foundation.h>


typedef int (^Myblock)(int, int);

int main(int argc, const char * argv[])
{

    Myblock myblock;
    myblock = ^(int a, int b){
        return a-b;
    };
    
    int sum = myblock(5, 3);
    NSLog(@"%d", sum);
    
    
    return 0;
}

void test2()
{
    int (^sumBlcok)(int, int) = ^(int a, int b){
        return a+b;
    };
    
    int sum = sumBlcok(5, 6);
    NSLog(@"%d", sum);
}


void test()
{
    void (^myblock)() = ^{
        NSLog(@"myblock");
    };
    
    
    myblock();
}

 

block

标签:

原文地址:http://www.cnblogs.com/jsnan/p/4340478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!