Block C->A

界面传值

单利 .h

typedef void (^callBlock)(NSString *str);

@interface Global : NSObject

@property (nonatomic, copy) callBlock callblock;

+ (instancetype)manager;

- (void)readBlock:(callBlock)block;
- (void)setBlock:(NSString *)str;

@end

.m

@implementation Global

+ (instancetype)manager
{
    static Global *_manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (_manager == nil) {
            _manager = [[Global alloc]init];
        }
    });
    return _manager;
}

- (void)readBlock:(callBlock)block{
    _callblock = [block copy];
}
- (void)setBlock:(NSString *)str{
    if (_callblock) {
        _callblock(str);
    }
}

@end

你可能感兴趣的:(Block C->A)