ios ~ Block 一般用法:

作者: 阳光下的叶子呵 | 来源:发表于2022-08-18 15:25 被阅读0次

同一个block方法的写法:

第一种写法:
typedef void(^ClickSolarTermBlock) (GWHome_SolarTermModel *solarTermModel);
@property (nonatomic, copy) ClickSolarTermBlock clickSolarTermBlock;

第二种写法:
@property (nonatomic, copy) void (^clickSolarTermBlock) (GWHome_SolarTermModel *solarTermModel);

使用:

if (self.clickSolarTermBlock) {
    self.clickSolarTermBlock(model);
}

回调:

__weak typeof(self) weakSelf = self;
GWHome_SolarTermsTreeCTRL *solarTermsTreeVC = [[GWHome_SolarTermsTreeCTRL alloc] init];
solarTermsTreeVC.selectSolarTermBlock = ^(GWHome_SolarTermModel * _Nonnull select_solarTermModel) {

    weakSelf.solarTermModel = select_solarTermModel;
    weakSelf.detailTableHeaderView.solarTermModel = weakSelf.solarTermModel;
    [weakSelf.detailTableHeaderView refreshSolarTermsDetailTableHeaderView];

};
[self.navigationController pushViewController:solarTermsTreeVC animated:YES];

相关文章

网友评论

    本文标题:ios ~ Block 一般用法:

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