Block备忘

2018-05-11  本文已影响9人  _小圆球_
#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


tmp7b2ff16e.png
上一篇 下一篇

猜你喜欢

热点阅读