// 代码块的声明
void (^MyBlock)();
//实现
MyBlock =^()
{
NSLog(@"测试");
};
//调用
MyBlock();
// 代码块的声明
NSInteger (^MyBlockAdd)(NSInteger x,NSInteger y);
MyBlockAdd=^(NSInteger x,NSInteger y)
{
//NSLog(@"%ld",x+y);
return x+y;
};//实现
NSInteger num =MyBlockAdd(27,33);//调用
NSLog(@"num=%ld",num);
Block 简单代码块的声明、实现与调用
原文:http://www.cnblogs.com/Always-LuoHan/p/5270196.html