From 8f289d99771429d09573e9342d10a84123c93276 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Mon, 19 Oct 2015 22:37:23 -0700 Subject: [PATCH 01/15] Back internal kind collection with a set --- AsyncDisplayKit/ASCollectionView.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index b312b86c..e124ecd2 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -153,7 +153,7 @@ static BOOL _isInterceptedSelector(SEL sel) CGSize _maxSizeForNodesConstrainedSize; BOOL _ignoreMaxSizeChange; - NSMutableArray *_registeredSupplementaryKinds; + NSMutableSet *_registeredSupplementaryKinds; /** * If YES, the `UICollectionView` will reload its data on next layout pass so we should not forward any updates to it. @@ -232,7 +232,7 @@ static BOOL _isInterceptedSelector(SEL sel) _layoutDelegate = [self flowLayoutInspector]; } - _registeredSupplementaryKinds = [NSMutableArray array]; + _registeredSupplementaryKinds = [NSMutableSet set]; self.backgroundColor = [UIColor whiteColor]; @@ -745,7 +745,7 @@ static BOOL _isInterceptedSelector(SEL sel) - (NSArray *)supplementaryNodeKindsInDataController:(ASCollectionDataController *)dataController { - return _registeredSupplementaryKinds; + return [_registeredSupplementaryKinds allObjects]; } - (ASSizeRange)dataController:(ASCollectionDataController *)dataController constrainedSizeForSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath From 11076b115e2c1fb49a599d44c92da773d557ec17 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Mon, 19 Oct 2015 22:45:30 -0700 Subject: [PATCH 02/15] Used cached layout value in node remeasurement --- AsyncDisplayKit/Details/ASDataController.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index 400a1161..c8191b3a 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -15,6 +15,7 @@ #import "ASDisplayNode.h" #import "ASMultidimensionalArrayUtils.h" #import "ASDisplayNodeInternal.h" +#import "ASLayout.h" //#define LOG(...) NSLog(__VA_ARGS__) #define LOG(...) @@ -818,8 +819,8 @@ static void *kASSizingQueueContext = &kASSizingQueueContext; [section enumerateObjectsUsingBlock:^(ASCellNode *node, NSUInteger rowIndex, BOOL *stop) { NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:sectionIndex]; ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:kind atIndexPath:indexPath]; - [node measureWithSizeRange:constrainedSize]; - node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height); + ASLayout *layout = [node measureWithSizeRange:constrainedSize]; + node.frame = CGRectMake(0.0f, 0.0f, layout.size.width, layout.size.height); }]; }]; }]; From 9697edac33377302fa35267de777cced29a58f83 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Mon, 19 Oct 2015 22:54:48 -0700 Subject: [PATCH 03/15] Fix conditional block style --- AsyncDisplayKit/Details/ASDataController.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index c8191b3a..c467716f 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -186,8 +186,9 @@ static void *kASSizingQueueContext = &kASSizingQueueContext; dispatch_group_wait(layoutGroup, DISPATCH_TIME_FOREVER); free(nodeBoundSizes); - if (completionBlock) + if (completionBlock) { completionBlock(nodes, indexPaths); + } } - (ASSizeRange)constrainedSizeForNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath From 5ca14486b6de91d9008a545033b6e52cc0ffab94 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 21:41:30 -0700 Subject: [PATCH 04/15] Make array instantiation consistent --- AsyncDisplayKit/Details/ASCollectionDataController.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsyncDisplayKit/Details/ASCollectionDataController.mm b/AsyncDisplayKit/Details/ASCollectionDataController.mm index 45f1d3af..1e3f7029 100644 --- a/AsyncDisplayKit/Details/ASCollectionDataController.mm +++ b/AsyncDisplayKit/Details/ASCollectionDataController.mm @@ -61,7 +61,7 @@ NSUInteger sectionCount = [self.collectionDataSource dataController:self numberOfSectionsForSupplementaryNodeOfKind:kind]; NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionCount]; for (int i = 0; i < sectionCount; i++) { - [sections addObject:[[NSMutableArray alloc] init]]; + [sections addObject:[NSMutableArray array]]; } [self insertSections:sections ofKind:kind atIndexSet:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, sectionCount)] completion:nil]; From 413307a9738cf55646f3a4c693e76d356d09198f Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 21:43:55 -0700 Subject: [PATCH 05/15] Assert flow layout inspector always initializes with a flow layout --- AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m index e6802049..b09f030c 100644 --- a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m +++ b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m @@ -11,6 +11,7 @@ #import "ASCollectionViewFlowLayoutInspector.h" #import "ASCollectionView.h" +#import "ASAssert.h" @implementation ASCollectionViewFlowLayoutInspector { BOOL _delegateImplementsReferenceSizeForHeader; @@ -24,7 +25,7 @@ self = [super init]; if (flowLayout == nil) { - return nil; + ASDisplayNodeAssert(NO, @"Should never create a layout inspector without a layout"); } if (self != nil) { From ad82c72eb47f2c2617c5af51fd45a4b55858343b Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 21:49:38 -0700 Subject: [PATCH 06/15] Cache flow layout delegate in local variable --- .../Details/ASCollectionViewFlowLayoutInspector.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m index b09f030c..0ef9f903 100644 --- a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m +++ b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m @@ -41,8 +41,9 @@ _delegateImplementsReferenceSizeForHeader = nil; _delegateImplementsReferenceSizeForFooter = nil; } else { - _delegateImplementsReferenceSizeForHeader = [[self delegateForCollectionView:collectionView] respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)]; - _delegateImplementsReferenceSizeForFooter = [[self delegateForCollectionView:collectionView] respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)]; + id delegate = [self delegateForCollectionView:collectionView]; + _delegateImplementsReferenceSizeForHeader = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)]; + _delegateImplementsReferenceSizeForFooter = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)]; } } From 56457249840498409824d329526da05350f8779e Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 22:16:42 -0700 Subject: [PATCH 07/15] Use pointer comparison helpers for string equality --- .../Details/ASCollectionViewFlowLayoutInspector.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m index 0ef9f903..beb654d0 100644 --- a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m +++ b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m @@ -12,6 +12,7 @@ #import "ASCollectionView.h" #import "ASAssert.h" +#import "ASEqualityHelpers.h" @implementation ASCollectionViewFlowLayoutInspector { BOOL _delegateImplementsReferenceSizeForHeader; @@ -79,13 +80,13 @@ - (CGSize)sizeForSupplementaryViewOfKind:(NSString *)kind inSection:(NSUInteger)section collectionView:(ASCollectionView *)collectionView { - if ([kind isEqualToString:UICollectionElementKindSectionHeader]) { + if (ASObjectIsEqual(kind, UICollectionElementKindSectionHeader)) { if (_delegateImplementsReferenceSizeForHeader) { return [[self delegateForCollectionView:collectionView] collectionView:collectionView layout:_layout referenceSizeForHeaderInSection:section]; } else { return [self.layout headerReferenceSize]; } - } else if ([kind isEqualToString:UICollectionElementKindSectionFooter]) { + } else if (ASObjectIsEqual(kind, UICollectionElementKindSectionFooter)) { if (_delegateImplementsReferenceSizeForFooter) { return [[self delegateForCollectionView:collectionView] collectionView:collectionView layout:_layout referenceSizeForFooterInSection:section]; } else { From 5736e7c2d24f490bcc4fe6b631a7e1ac31c5357d Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 22:29:10 -0700 Subject: [PATCH 08/15] Clarify editing transaction documentation --- AsyncDisplayKit/Details/ASDataController+Subclasses.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AsyncDisplayKit/Details/ASDataController+Subclasses.h b/AsyncDisplayKit/Details/ASDataController+Subclasses.h index 3e334493..23c28e9a 100644 --- a/AsyncDisplayKit/Details/ASDataController+Subclasses.h +++ b/AsyncDisplayKit/Details/ASDataController+Subclasses.h @@ -74,8 +74,8 @@ /** * Notifies the subclass to perform any work needed before the data controller is reloaded entirely * - * @discussion This method will be performed before the data controller enters its editing queue, usually on the main - * thread. The data source is locked at this point and accessing it is safe. Use this method to set up any nodes or + * @discussion This method will be performed before the data controller enters its editing queue. + * The data source is locked at this point and accessing it is safe. Use this method to set up any nodes or * data stores before entering into editing the backing store on a background thread. */ - (void)prepareForReloadData; @@ -92,8 +92,8 @@ /** * Notifies the subclass to perform setup before sections are inserted in the data controller * - * @discussion This method will be performed before the data controller enters its editing queue, usually on the main - * thread. The data source is locked at this point and accessing it is safe. Use this method to set up any nodes or + * @discussion This method will be performed before the data controller enters its editing queue. + * The data source is locked at this point and accessing it is safe. Use this method to set up any nodes or * data stores before entering into editing the backing store on a background thread. * * @param sections Indices of sections to be inserted From 45ff74b6048c26be66b22cadc4a7bb7a04f89162 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 22:38:41 -0700 Subject: [PATCH 09/15] Remove array fallback on editing node index paths --- AsyncDisplayKit/Details/ASDataController.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index c467716f..009d1432 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -220,8 +220,10 @@ static void *kASSizingQueueContext = &kASSizingQueueContext; - (void)deleteNodesOfKind:(NSString *)kind atIndexPaths:(NSArray *)indexPaths completion:(void (^)(NSArray *nodes, NSArray *indexPaths))completionBlock { - if (indexPaths.count == 0) + if (indexPaths.count == 0) { return; + } + LOG(@"_deleteNodesAtIndexPaths:%@ ofKind:%@, full index paths in _editingNodes = %@", indexPaths, kind, ASIndexPathsForMultidimensionalArray(_editingNodes[kind])); NSMutableArray *editingNodes = _editingNodes[kind]; ASDeleteElementsInMultidimensionalArrayAtIndexPaths(editingNodes, indexPaths); @@ -851,7 +853,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext; - (NSArray *)indexPathsForEditingNodesOfKind:(NSString *)kind { - return _editingNodes[kind] != nil ? ASIndexPathsForMultidimensionalArray(_editingNodes[kind]) : [NSArray array]; + return _editingNodes[kind] != nil ? ASIndexPathsForMultidimensionalArray(_editingNodes[kind]) : nil; } - (NSMutableArray *)editingNodesOfKind:(NSString *)kind From db0a0326d70741b316a0cf06e3fe177e2d159e17 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 22:59:10 -0700 Subject: [PATCH 10/15] Rename layoutDelegate to layoutInspector in ASCollectionView --- AsyncDisplayKit/ASCollectionView.h | 2 +- AsyncDisplayKit/ASCollectionView.mm | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index 14ec90f8..2b8f9029 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -90,7 +90,7 @@ * collection view layout subclasses will need to provide their own implementation of an inspector object for their * supplementary views to be compatible with `ASCollectionView`'s supplementary node support. */ -@property (nonatomic, weak) id layoutDelegate; +@property (nonatomic, weak) id layoutInspector; /** * Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread. diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index e124ecd2..31191d42 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -229,7 +229,7 @@ static BOOL _isInterceptedSelector(SEL sel) // Register the default layout inspector delegate for flow layouts only, custom layouts // will need to roll their own ASCollectionViewLayoutInspecting implementation and set a layout delegate if ([layout asdk_isFlowLayout]) { - _layoutDelegate = [self flowLayoutInspector]; + _layoutInspector = [self flowLayoutInspector]; } _registeredSupplementaryKinds = [NSMutableSet set]; @@ -341,7 +341,7 @@ static BOOL _isInterceptedSelector(SEL sel) [super setCollectionViewLayout:collectionViewLayout]; if ([collectionViewLayout asdk_isFlowLayout]) { _flowLayoutInspector = nil; - _layoutDelegate = [self flowLayoutInspector]; + _layoutInspector = [self flowLayoutInspector]; } } @@ -750,20 +750,20 @@ static BOOL _isInterceptedSelector(SEL sel) - (ASSizeRange)dataController:(ASCollectionDataController *)dataController constrainedSizeForSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { - ASDisplayNodeAssert(_layoutDelegate != nil, @"To support supplementary nodes in ASCollectionView, it must have a layoutDelegate for layout inspection. (See ASCollectionViewFlowLayoutInspector for an example.)"); - return [_layoutDelegate collectionView:self constrainedSizeForSupplementaryNodeOfKind:kind atIndexPath:indexPath]; + ASDisplayNodeAssert(_layoutInspector != nil, @"To support supplementary nodes in ASCollectionView, it must have a layoutDelegate for layout inspection. (See ASCollectionViewFlowLayoutInspector for an example.)"); + return [_layoutInspector collectionView:self constrainedSizeForSupplementaryNodeOfKind:kind atIndexPath:indexPath]; } - (NSUInteger)dataController:(ASCollectionDataController *)dataController supplementaryNodesOfKind:(NSString *)kind inSection:(NSUInteger)section { - ASDisplayNodeAssert(_layoutDelegate != nil, @"To support supplementary nodes in ASCollectionView, it must have a layoutDelegate for layout inspection. (See ASCollectionViewFlowLayoutInspector for an example.)"); - return [_layoutDelegate collectionView:self supplementaryNodesOfKind:kind inSection:section]; + ASDisplayNodeAssert(_layoutInspector != nil, @"To support supplementary nodes in ASCollectionView, it must have a layoutDelegate for layout inspection. (See ASCollectionViewFlowLayoutInspector for an example.)"); + return [_layoutInspector collectionView:self supplementaryNodesOfKind:kind inSection:section]; } - (NSUInteger)dataController:(ASCollectionDataController *)dataController numberOfSectionsForSupplementaryNodeOfKind:(NSString *)kind; { - ASDisplayNodeAssert(_layoutDelegate != nil, @"To support supplementary nodes in ASCollectionView, it must have a layoutDelegate for layout inspection. (See ASCollectionViewFlowLayoutInspector for an example.)"); - return [_layoutDelegate collectionView:self numberOfSectionsForSupplementaryNodeOfKind:kind]; + ASDisplayNodeAssert(_layoutInspector != nil, @"To support supplementary nodes in ASCollectionView, it must have a layoutDelegate for layout inspection. (See ASCollectionViewFlowLayoutInspector for an example.)"); + return [_layoutInspector collectionView:self numberOfSectionsForSupplementaryNodeOfKind:kind]; } #pragma mark - ASRangeControllerDelegate. From 084d60883bcdbda434ab9f3db8637de956eb97da Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 23:04:21 -0700 Subject: [PATCH 11/15] Add assertion to flow layout inspector down casting --- AsyncDisplayKit/ASCollectionView.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 31191d42..08f4b435 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -256,6 +256,7 @@ static BOOL _isInterceptedSelector(SEL sel) { if (_flowLayoutInspector == nil) { UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionViewLayout; + ASDisplayNodeAssertNotNil(layout, @"Collection view layout must be a flow layout to use the built-in inspector"); _flowLayoutInspector = [[ASCollectionViewFlowLayoutInspector alloc] initWithCollectionView:self flowLayout:layout]; } From e8ce7fcbb2ab6cc2c0b4825cd756dd7ee2a43103 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 23:14:54 -0700 Subject: [PATCH 12/15] Clean up caching of collection view delegate selectors on the inspector --- AsyncDisplayKit/ASCollectionView.mm | 2 +- .../Details/ASCollectionViewFlowLayoutInspector.h | 10 ++++++++-- .../Details/ASCollectionViewFlowLayoutInspector.m | 7 +++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 08f4b435..01b4927a 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -334,7 +334,7 @@ static BOOL _isInterceptedSelector(SEL sel) _asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0); } - [_flowLayoutInspector cacheSelectorsForCollectionView:self]; + [_layoutInspector didChangeCollectionViewDelegate:asyncDelegate]; } - (void)setCollectionViewLayout:(UICollectionViewLayout *)collectionViewLayout diff --git a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.h b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.h index 5aab03e0..179b8808 100644 --- a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.h +++ b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.h @@ -11,6 +11,7 @@ #import @class ASCollectionView; +@protocol ASCollectionViewDelegate; @protocol ASCollectionViewLayoutInspecting @@ -29,6 +30,13 @@ */ - (NSUInteger)collectionView:(ASCollectionView *)collectionView supplementaryNodesOfKind:(NSString *)kind inSection:(NSUInteger)section; +/** + * Allow the inspector to respond to delegate changes. + * + * @discussion A great time to update perform selector caches! + */ +- (void)didChangeCollectionViewDelegate:(id)delegate; + @end @interface ASCollectionViewFlowLayoutInspector : NSObject @@ -37,6 +45,4 @@ - (instancetype)initWithCollectionView:(ASCollectionView *)collectionView flowLayout:(UICollectionViewFlowLayout *)flowLayout; -- (void)cacheSelectorsForCollectionView:(ASCollectionView *)collectionView; - @end diff --git a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m index beb654d0..e90cd461 100644 --- a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m +++ b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m @@ -30,19 +30,18 @@ } if (self != nil) { - [self cacheSelectorsForCollectionView:collectionView]; + [self didChangeCollectionViewDelegate:collectionView.asyncDelegate]; _layout = flowLayout; } return self; } -- (void)cacheSelectorsForCollectionView:(ASCollectionView *)collectionView +- (void)didChangeCollectionViewDelegate:(id)delegate; { - if (collectionView == nil) { + if (delegate == nil) { _delegateImplementsReferenceSizeForHeader = nil; _delegateImplementsReferenceSizeForFooter = nil; } else { - id delegate = [self delegateForCollectionView:collectionView]; _delegateImplementsReferenceSizeForHeader = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)]; _delegateImplementsReferenceSizeForFooter = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)]; } From e9708633bcb3f3ffe30c2e6a3611f7e7f8838d6f Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Wed, 21 Oct 2015 23:16:31 -0700 Subject: [PATCH 13/15] Remove stubbed collection view layout setter behavior --- AsyncDisplayKit/ASCollectionView.mm | 9 --------- 1 file changed, 9 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 01b4927a..bf761b04 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -337,15 +337,6 @@ static BOOL _isInterceptedSelector(SEL sel) [_layoutInspector didChangeCollectionViewDelegate:asyncDelegate]; } -- (void)setCollectionViewLayout:(UICollectionViewLayout *)collectionViewLayout -{ - [super setCollectionViewLayout:collectionViewLayout]; - if ([collectionViewLayout asdk_isFlowLayout]) { - _flowLayoutInspector = nil; - _layoutInspector = [self flowLayoutInspector]; - } -} - - (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType { [_layoutController setTuningParameters:tuningParameters forRangeType:rangeType]; From d9ea1b52ea958a37303202cb8b9e1ecf664eb1b5 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Thu, 22 Oct 2015 15:27:48 -0700 Subject: [PATCH 14/15] Fix unit tests --- AsyncDisplayKitTests/ASCollectionViewTests.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AsyncDisplayKitTests/ASCollectionViewTests.m b/AsyncDisplayKitTests/ASCollectionViewTests.m index db993713..59a081ec 100644 --- a/AsyncDisplayKitTests/ASCollectionViewTests.m +++ b/AsyncDisplayKitTests/ASCollectionViewTests.m @@ -91,15 +91,15 @@ { UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; ASCollectionView *collectionView = [[ASCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; - XCTAssert(collectionView.layoutDelegate != nil, @"should automatically set a layout delegate for flow layouts"); - XCTAssert([collectionView.layoutDelegate isKindOfClass:[ASCollectionViewFlowLayoutInspector class]], @"should have a flow layout inspector by default"); + XCTAssert(collectionView.layoutInspector != nil, @"should automatically set a layout delegate for flow layouts"); + XCTAssert([collectionView.layoutInspector isKindOfClass:[ASCollectionViewFlowLayoutInspector class]], @"should have a flow layout inspector by default"); } - (void)testThatItDoesNotSetALayoutInspectorForCustomLayouts { UICollectionViewLayout *layout = [[UICollectionViewLayout alloc] init]; ASCollectionView *collectionView = [[ASCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; - XCTAssert(collectionView.layoutDelegate == nil, @"should not set a layout delegate for custom layouts"); + XCTAssert(collectionView.layoutInspector == nil, @"should not set a layout delegate for custom layouts"); } - (void)testThatRegisteringASupplementaryNodeStoresItForIntrospection From 6569893c239efd4b200adb6f5e27c8ec5a2c6a54 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Thu, 22 Oct 2015 18:54:07 -0700 Subject: [PATCH 15/15] Reset inspector selector implementation cache correctly --- AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m index e90cd461..5ce3b9bf 100644 --- a/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m +++ b/AsyncDisplayKit/Details/ASCollectionViewFlowLayoutInspector.m @@ -39,8 +39,8 @@ - (void)didChangeCollectionViewDelegate:(id)delegate; { if (delegate == nil) { - _delegateImplementsReferenceSizeForHeader = nil; - _delegateImplementsReferenceSizeForFooter = nil; + _delegateImplementsReferenceSizeForHeader = NO; + _delegateImplementsReferenceSizeForFooter = NO; } else { _delegateImplementsReferenceSizeForHeader = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)]; _delegateImplementsReferenceSizeForFooter = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)];