标签:
//声明Blcok,返回一个对象
__block int i = 0;
Home *(^count)(void) = ^ {
i += 1;
Home *home =[[Home alloc] init];
home.title = @"DD";
return home;
};
//返回一个字符串
NSString *(^string)(void) = ^ {
return @"aa";
};
NSLog(@"%@", count().title); // 1
NSLog(@"%@", string()); // 2
//block当作一个参数传递
[self testBlock:^(int age) {
NSLog(@"%d",age);
}];
return YES;
-(void)testBlock:(void(^)(int age))cc
{
cc(10);
}
标签:
原文地址:http://www.cnblogs.com/xiaoyixinfeng/p/4314730.html