Add assert for ASCollectionDataSource implementing collectionView:constrainedSizeForNodeAtIndexPath: instead of ASCollectionDelegate (#2165)

This commit is contained in:
Michael Schneider
2016-08-29 16:44:11 -07:00
committed by Adlai Holler
parent 8d86bb6db3
commit 1849c41b03
2 changed files with 74 additions and 0 deletions

View File

@@ -63,6 +63,9 @@ static inline ASSizeRange NodeConstrainedSizeForScrollDirection(ASCollectionView
{
if (_delegateFlags.implementsConstrainedSizeForNodeAtIndexPath) {
return [collectionView.asyncDelegate collectionView:collectionView constrainedSizeForNodeAtIndexPath:indexPath];
} else {
// With 2.0 `collectionView:constrainedSizeForNodeAtIndexPath:` was moved to the delegate. Assert if not implemented on the delegate but on the data source
ASDisplayNodeAssert([collectionView.asyncDataSource respondsToSelector:@selector(collectionView:constrainedSizeForNodeAtIndexPath:)] == NO, @"collectionView:constrainedSizeForNodeAtIndexPath: was moved from the ASCollectionDataSource to the ASCollectionDataSource.");
}
return NodeConstrainedSizeForScrollDirection(collectionView);
@@ -143,6 +146,9 @@ static inline ASSizeRange NodeConstrainedSizeForScrollDirection(ASCollectionView
{
if (_delegateFlags.implementsConstrainedSizeForNodeAtIndexPath) {
return [collectionView.asyncDelegate collectionView:collectionView constrainedSizeForNodeAtIndexPath:indexPath];
} else {
// With 2.0 `collectionView:constrainedSizeForNodeAtIndexPath:` was moved to the delegate. Assert if not implemented on the delegate but on the data source
ASDisplayNodeAssert([collectionView.asyncDataSource respondsToSelector:@selector(collectionView:constrainedSizeForNodeAtIndexPath:)] == NO, @"collectionView:constrainedSizeForNodeAtIndexPath: was moved from the ASCollectionDataSource to the ASCollectionDataSource.");
}
CGSize itemSize = _layout.itemSize;