美文网首页
iOS 双层block嵌套的用法

iOS 双层block嵌套的用法

作者: 可乐小子 | 来源:发表于2021-11-09 14:36 被阅读0次
  • (void)setUpModel{
    XXModel *model = [XXModel new];

    __weak typeof(self) weakSelf = self;

    model.dodoBlock = ^(NSString *title) {

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

    };

    self.model = model;
    }

相关文章

网友评论

      本文标题:iOS 双层block嵌套的用法

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