-
__weak typeof(self) weakSelf = self;
解决循环引用
#import "ViewController.h"
typedef void (^myBlock)(NSDictionary *block);
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
int (^blk)(int) = ^ int (int count){
return count + 1;
};
int a = blk(2);
NSLog(@"a: %d",a);
[self BlockFunc:^(NSDictionary *block) {
NSLog(@"block: %@",block);
}];
}
- (void)BlockFunc:(myBlock)block
{
if (block) {
NSDictionary *b = @{@"key" : @"hello"};
block(b);
}
}
@end