RACObserve 监听弱单例会内存泄漏

2019-12-20  本文已影响0人  forping
+ (instancetype)sharedInstance{
    static __weak FPPhotosDataManger *instance;
    FPPhotosDataManger *strongInstance = instance;
    @synchronized (self) {
        if (strongInstance == nil) {
            strongInstance = [[self alloc] init];
            instance = strongInstance;
        }
    }
    return strongInstance;
}

[RACObserve(self, viewModel.dataManager.count) subscribeNext:^(id  _Nullable x) {
        @strongify(self)
        [self XXXX];
}];

暂未有有效的解决方案

上一篇 下一篇

猜你喜欢

热点阅读