#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
typedef int (^myBlock)(int a,int b); //此时myBlock是类型
myBlock num; //定义myBlock类型的变量num
num = ^(int a ,int b){ //赋值
return a+b;
};
NSLog(@"%d",num(10,20)); //调用
typedef void (^mublock5)();
mublock5 str = ^{ NSLog(@"xxxx"); }; //定义并赋值
str(); //调用
return 0;
}
|
|