欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

iOS 多层block

程序员文章站 2022-03-03 12:46:54
...
- (void)setShiFangUpModel{undefined
    SFModel *model = [SFModel new];
   
    __weak typeof(self) weakSelf = self;

    model.chuanZhiBlock = ^(NSString *title) {undefined

        __strong typeof(self) strongSelf = weakSelf;//第一层
        strongSelf.titleLabel.text = title;
        
        __weak typeof(self) weakSelf2 = strongSelf;
        strongSelf.model.chuanZhiBlock = ^(NSString *title2) {undefined

            __strong typeof(self) strongSelf2 = weakSelf2;//第二层
            strongSelf2.titleLabel.text = title2;
        };
    };