diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 25f7a285f3..d7a4890ecc 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -63,7 +63,6 @@ static BOOL _isInterceptedSelector(SEL sel) return nil; } - ASDisplayNodeAssert(target, @"target must not be nil"); ASDisplayNodeAssert(interceptor, @"interceptor must not be nil"); _target = target; @@ -125,7 +124,10 @@ static BOOL _isInterceptedSelector(SEL sel) _dataController = [[ASDataController alloc] init]; _dataController.delegate = _rangeController; _dataController.dataSource = self; - + + _proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:nil interceptor:self]; + super.delegate = (id)_proxyDelegate; + [self registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"_ASCollectionViewCell"]; return self; @@ -174,15 +176,9 @@ static BOOL _isInterceptedSelector(SEL sel) if (_asyncDelegate == asyncDelegate) return; - if (asyncDelegate == nil) { - _asyncDelegate = nil; - _proxyDelegate = nil; - super.delegate = nil; - } else { - _asyncDelegate = asyncDelegate; - _proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self]; - super.delegate = (id)_proxyDelegate; - } + _asyncDelegate = asyncDelegate; + _proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self]; + super.delegate = (id)_proxyDelegate; } - (ASRangeTuningParameters)rangeTuningParameters diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 123bc3b3a9..40c0666612 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -63,7 +63,6 @@ static BOOL _isInterceptedSelector(SEL sel) return nil; } - ASDisplayNodeAssert(target, @"target must not be nil"); ASDisplayNodeAssert(interceptor, @"interceptor must not be nil"); _target = target; @@ -135,6 +134,9 @@ static BOOL _isInterceptedSelector(SEL sel) _dataController.dataSource = self; _dataController.delegate = _rangeController; + _proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:nil interceptor:self]; + super.delegate = (id)_proxyDelegate; + return self; } @@ -173,15 +175,9 @@ static BOOL _isInterceptedSelector(SEL sel) if (_asyncDelegate == asyncDelegate) return; - if (asyncDelegate == nil) { - _asyncDelegate = nil; - _proxyDelegate = nil; - super.delegate = nil; - } else { - _asyncDelegate = asyncDelegate; - _proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self]; - super.delegate = (id)_proxyDelegate; - } + _asyncDelegate = asyncDelegate; + _proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:asyncDelegate interceptor:self]; + super.delegate = (id)_proxyDelegate; } - (void)reloadData