rac dangling pointer crash。

9 Views Asked by At
@weakify(self);
[[[RACObserve(self, waitTime) takeUntil:self.rac_willDeallocSignal] deliverOnMainThread] subscribeNext:^(id  _Nullable x) {
    @strongify(self);
    [self.watchFreeAdBtn setTitle:self.data.videoCardButton forState:UIControlStateNormal];
}];

- (UIButton *)watchFreeAdBtn {
    if (!_watchFreeAdBtn) {
        _watchFreeAdBtn = [[UIButton alloc] init];
        _watchFreeAdBtn.layer.cornerRadius = 14;
        if (!self.showVipDiscount) {
            _watchFreeAdBtn.backgroundColor = [UIColor ssLightColorWithName:SS_COLOR_BG_CARD_FF];
        } else {
            _watchFreeAdBtn.backgroundColor = [UIColor ssLightColorWithName:SS_COLOR_GRAY_03];
        }
    }
    return _watchFreeAdBtn;
}

This code ran to _watchFreeAdBtn.layer.cornerRadius = 14; and encountered a wild pointer crash. I would like to ask why the just created _watchFreeAdBtn was released. Is it related to RAC retaining self?

0

There are 0 best solutions below