Block备忘
作者:
_小圆球_ | 来源:发表于
2018-05-11 12:37 被阅读9次
-
__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
![](https://img.haomeiwen.com/i1182464/3c1506da5512c445.png)
tmp7b2ff16e.png
本文标题:Block备忘
本文链接:https://www.haomeiwen.com/subject/edrfdftx.html
网友评论