- (void)viewDidLoad {
[super viewDidLoad];
//block 1
int i=10; //在block块只读
__block int j=1; //在block可以修改的变量
int (^myblock)(int)=^(int num){
//可使用作用域内的变量
j=10;
return num*i;
};
NSLog(@"%d",myblock(10));
[self testBlock:^(NSString *str){
NSLog(@"%@",str);
}];
}
//block做参数
-(void)testBlock:(void (^)(NSString *str))theB
{
theB(@"dddd");
}