diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 73e61653f5..c9f52c1466 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -184,8 +184,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; { // Sometimes the UIKit classes can call back to their delegate even during deallocation, due to animation completion blocks etc. _isDeallocating = YES; + NSLog(@"before dealloc - delegate - %@, datasource - %@, proxyDelegate - %@, proxyDatasource - %@", self.asyncDelegate, self.asyncDataSource, _proxyDelegate, _proxyDataSource); [self setAsyncDelegate:nil]; [self setAsyncDataSource:nil]; + NSLog(@"after dealloc - delegate - %@, datasource - %@, proxyDelegate - %@, proxyDatasource - %@", self.asyncDelegate, self.asyncDataSource, _proxyDelegate, _proxyDataSource); } /** @@ -267,6 +269,8 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; _asyncDataSourceImplementsConstrainedSizeForNode = ([_asyncDataSource respondsToSelector:@selector(collectionView:constrainedSizeForNodeAtIndexPath:)] ? 1 : 0); } + NSLog(@"setAsyncDataSource - %@, proxy - %@, deallocating - %d", asyncDataSource, _proxyDataSource, _isDeallocating); + super.dataSource = (id)_proxyDataSource; } @@ -292,6 +296,8 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; _asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0); } + NSLog(@"setAsyncDelegate - %@, proxy - %@, deallocating - %d", asyncDelegate, _proxyDelegate, _isDeallocating); + super.delegate = (id)_proxyDelegate; [_layoutInspector didChangeCollectionViewDelegate:asyncDelegate]; diff --git a/AsyncDisplayKit/Details/ASDelegateProxy.m b/AsyncDisplayKit/Details/ASDelegateProxy.m index baaff1e62c..cd64c4827c 100644 --- a/AsyncDisplayKit/Details/ASDelegateProxy.m +++ b/AsyncDisplayKit/Details/ASDelegateProxy.m @@ -82,10 +82,8 @@ - (BOOL)respondsToSelector:(SEL)aSelector { - ASDisplayNodeAssert(_interceptor, @"interceptor must not be nil"); - if ([self interceptsSelector:aSelector]) { - return YES; + return (_interceptor != nil); } else { // Also return NO if _target has become nil due to zeroing weak reference (or placeholder initialization). return [_target respondsToSelector:aSelector]; @@ -94,8 +92,6 @@ - (id)forwardingTargetForSelector:(SEL)aSelector { - ASDisplayNodeAssert(_interceptor, @"interceptor must not be nil"); - if ([self interceptsSelector:aSelector]) { return _interceptor; } else {