美文网首页
Block C->A

Block C->A

作者: yuezishenyou | 来源:发表于2017-11-07 18:06 被阅读0次

界面传值

单利 .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

      本文链接:https://www.haomeiwen.com/subject/nkgjmxtx.html