Skip to content

Commit 1775bf2

Browse files
author
Adlai Holler
authored
ASDataController: Adopt ASElementMap (facebookarchive#3073)
* Build ASElementMap and use it * Keep building! * Clean up * Restrict ASDataController subclassing * Clean up more * More rearranging * Dear lord it's time for bed * Make things clearer * Sadly remove subclassing restriction for ASDataController * Remove dead initializer
1 parent 42a2959 commit 1775bf2

19 files changed

+620
-456
lines changed

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@
301301
B350625D1B0111740018CF92 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943141A1575670030A7D0 /* Photos.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
302302
B350625E1B0111780018CF92 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943121A1575630030A7D0 /* AssetsLibrary.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
303303
C78F7E2B1BF7809800CDEAFC /* ASTableNode.h in Headers */ = {isa = PBXBuildFile; fileRef = B0F880581BEAEC7500D17647 /* ASTableNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
304+
CC034A011E5FAF9700626263 /* ASElementMap.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0349FF1E5FAF9700626263 /* ASElementMap.h */; };
305+
CC034A021E5FAF9700626263 /* ASElementMap.m in Sources */ = {isa = PBXBuildFile; fileRef = CC034A001E5FAF9700626263 /* ASElementMap.m */; };
304306
CC051F1F1D7A286A006434CB /* ASCALayerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC051F1E1D7A286A006434CB /* ASCALayerTests.m */; };
305307
CC0AEEA41D66316E005D1C78 /* ASUICollectionViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0AEEA31D66316E005D1C78 /* ASUICollectionViewTests.m */; };
306308
CC0F885B1E42807F00576FED /* ASCollectionViewFlowLayoutInspector.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0F88591E42807F00576FED /* ASCollectionViewFlowLayoutInspector.m */; };
@@ -313,6 +315,8 @@
313315
CC0F886C1E4286FA00576FED /* ReferenceImages_64 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F88691E4286FA00576FED /* ReferenceImages_64 */; };
314316
CC0F886D1E4286FA00576FED /* ReferenceImages_iOS_10 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */; };
315317
CC11F97A1DB181180024D77B /* ASNetworkImageNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */; };
318+
CC2F65EE1E5FFB1600DA57C9 /* ASMutableElementMap.h in Headers */ = {isa = PBXBuildFile; fileRef = CC2F65EC1E5FFB1600DA57C9 /* ASMutableElementMap.h */; };
319+
CC2F65EF1E5FFB1600DA57C9 /* ASMutableElementMap.m in Sources */ = {isa = PBXBuildFile; fileRef = CC2F65ED1E5FFB1600DA57C9 /* ASMutableElementMap.m */; };
316320
CC3B20841C3F76D600798563 /* ASPendingStateController.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3B20811C3F76D600798563 /* ASPendingStateController.h */; settings = {ATTRIBUTES = (Private, ); }; };
317321
CC3B20861C3F76D600798563 /* ASPendingStateController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC3B20821C3F76D600798563 /* ASPendingStateController.mm */; };
318322
CC3B208A1C3F7A5400798563 /* ASWeakSet.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3B20871C3F7A5400798563 /* ASWeakSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -684,6 +688,8 @@
684688
B30BF6511C5964B0004FCD53 /* ASLayoutManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ASLayoutManager.m; path = TextKit/ASLayoutManager.m; sourceTree = "<group>"; };
685689
B35061DA1B010EDF0018CF92 /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AsyncDisplayKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
686690
BDC2D162BD55A807C1475DA5 /* Pods-AsyncDisplayKitTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AsyncDisplayKitTests.profile.xcconfig"; path = "Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests.profile.xcconfig"; sourceTree = "<group>"; };
691+
CC0349FF1E5FAF9700626263 /* ASElementMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASElementMap.h; sourceTree = "<group>"; };
692+
CC034A001E5FAF9700626263 /* ASElementMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASElementMap.m; sourceTree = "<group>"; };
687693
CC051F1E1D7A286A006434CB /* ASCALayerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCALayerTests.m; sourceTree = "<group>"; };
688694
CC0AEEA31D66316E005D1C78 /* ASUICollectionViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASUICollectionViewTests.m; sourceTree = "<group>"; };
689695
CC0F88591E42807F00576FED /* ASCollectionViewFlowLayoutInspector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCollectionViewFlowLayoutInspector.m; sourceTree = "<group>"; };
@@ -695,6 +701,8 @@
695701
CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_iOS_10; sourceTree = "<group>"; };
696702
CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASNetworkImageNodeTests.m; sourceTree = "<group>"; };
697703
CC2E317F1DAC353700EEE891 /* ASCollectionView+Undeprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASCollectionView+Undeprecated.h"; sourceTree = "<group>"; };
704+
CC2F65EC1E5FFB1600DA57C9 /* ASMutableElementMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMutableElementMap.h; sourceTree = "<group>"; };
705+
CC2F65ED1E5FFB1600DA57C9 /* ASMutableElementMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASMutableElementMap.m; sourceTree = "<group>"; };
698706
CC3B20811C3F76D600798563 /* ASPendingStateController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASPendingStateController.h; sourceTree = "<group>"; };
699707
CC3B20821C3F76D600798563 /* ASPendingStateController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASPendingStateController.mm; sourceTree = "<group>"; };
700708
CC3B20871C3F7A5400798563 /* ASWeakSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASWeakSet.h; sourceTree = "<group>"; };
@@ -1124,6 +1132,10 @@
11241132
058D0A01195D050800B7D73C /* Private */ = {
11251133
isa = PBXGroup;
11261134
children = (
1135+
CC2F65EC1E5FFB1600DA57C9 /* ASMutableElementMap.h */,
1136+
CC2F65ED1E5FFB1600DA57C9 /* ASMutableElementMap.m */,
1137+
CC0349FF1E5FAF9700626263 /* ASElementMap.h */,
1138+
CC034A001E5FAF9700626263 /* ASElementMap.m */,
11271139
CC55A70F1E52A0F200594372 /* ASResponderChainEnumerator.h */,
11281140
CC55A7101E52A0F200594372 /* ASResponderChainEnumerator.m */,
11291141
6947B0BB1E36B4E30007C478 /* Layout */,
@@ -1466,6 +1478,7 @@
14661478
CC57EAF71E3939350034C595 /* ASCollectionView+Undeprecated.h in Headers */,
14671479
B35062521B010EFD0018CF92 /* ASDisplayNodeInternal.h in Headers */,
14681480
AC7A2C181BDE11DF0093FE1A /* ASTableViewInternal.h in Headers */,
1481+
CC034A011E5FAF9700626263 /* ASElementMap.h in Headers */,
14691482
B35062531B010EFD0018CF92 /* ASImageNode+CGExtras.h in Headers */,
14701483
254C6B7F1BF94DF4003EC431 /* ASTextKitTruncating.h in Headers */,
14711484
CC58AA4B1E398E1D002C8CB4 /* ASBlockTypes.h in Headers */,
@@ -1498,6 +1511,7 @@
14981511
9CDC18CD1B910E12004965E2 /* ASLayoutElementPrivate.h in Headers */,
14991512
B35062201B010EFD0018CF92 /* ASLayoutController.h in Headers */,
15001513
B35062211B010EFD0018CF92 /* ASLayoutRangeType.h in Headers */,
1514+
CC2F65EE1E5FFB1600DA57C9 /* ASMutableElementMap.h in Headers */,
15011515
34EFC76A1B701CE600AD841F /* ASLayoutSpec.h in Headers */,
15021516
B350625C1B010F070018CF92 /* ASLog.h in Headers */,
15031517
CC3B208A1C3F7A5400798563 /* ASWeakSet.h in Headers */,
@@ -1832,6 +1846,7 @@
18321846
68B8A4E41CBDB958007E4543 /* ASWeakProxy.m in Sources */,
18331847
9C70F20A1CDBE949007D6C76 /* ASTableNode.mm in Sources */,
18341848
69CB62AE1CB8165900024920 /* _ASDisplayViewAccessiblity.mm in Sources */,
1849+
CC034A021E5FAF9700626263 /* ASElementMap.m in Sources */,
18351850
B35061F61B010EFD0018CF92 /* ASCollectionView.mm in Sources */,
18361851
509E68641B3AEDB7009B9150 /* ASCollectionViewLayoutController.mm in Sources */,
18371852
B35061F91B010EFD0018CF92 /* ASControlNode.mm in Sources */,
@@ -1857,6 +1872,7 @@
18571872
B350621E1B010EFD0018CF92 /* ASHighlightOverlayLayer.mm in Sources */,
18581873
9CC606651D24DF9E006581A0 /* NSIndexSet+ASHelpers.m in Sources */,
18591874
CC0F885F1E4280B800576FED /* _ASCollectionViewCell.m in Sources */,
1875+
CC2F65EF1E5FFB1600DA57C9 /* ASMutableElementMap.m in Sources */,
18601876
B35062541B010EFD0018CF92 /* ASImageNode+CGExtras.m in Sources */,
18611877
6947B0C01E36B4E30007C478 /* ASStackUnpositionedLayout.mm in Sources */,
18621878
68355B401CB57A69001D4E68 /* ASImageContainerProtocolCategories.m in Sources */,

AsyncDisplayKit/ASCellNode+Internal.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
NS_ASSUME_NONNULL_BEGIN
1616

17+
@class ASCollectionElement;
18+
1719
@protocol ASCellNodeInteractionDelegate <NSObject>
1820

1921
/**
@@ -58,10 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
5860
*/
5961
@property (nonatomic, strong, nullable) UICollectionViewLayoutAttributes *layoutAttributes;
6062

61-
/// readwrite variant of the readonly public property.
62-
@property (nonatomic, copy, nullable) NSString *supplementaryElementKind;
63-
64-
@property (nonatomic, copy, nullable) NSIndexPath *cachedIndexPath;
63+
@property (weak, nullable) ASCollectionElement *collectionElement;
6564

6665
@property (nonatomic, weak, nullable) ASDisplayNode *owningNode;
6766

AsyncDisplayKit/ASCellNode.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#import <AsyncDisplayKit/ASInternalHelpers.h>
1515
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
1616
#import <AsyncDisplayKit/ASCollectionView+Undeprecated.h>
17+
#import <AsyncDisplayKit/ASCollectionElement.h>
1718
#import <AsyncDisplayKit/ASTableView+Undeprecated.h>
1819
#import <AsyncDisplayKit/_ASDisplayView.h>
1920
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
@@ -389,6 +390,12 @@ - (void)handleVisibilityChange:(BOOL)isVisible
389390

390391
return result;
391392
}
393+
394+
- (NSString *)supplementaryElementKind
395+
{
396+
return self.collectionElement.supplementaryElementKind;
397+
}
398+
392399
@end
393400

394401

AsyncDisplayKit/ASCollectionNode.mm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#import <AsyncDisplayKit/ASCollectionNode.h>
1414

15+
#import <AsyncDisplayKit/ASCollectionElement.h>
16+
#import <AsyncDisplayKit/ASElementMap.h>
1517
#import <AsyncDisplayKit/ASCollectionInternal.h>
1618
#import <AsyncDisplayKit/ASCollectionViewLayoutFacilitatorProtocol.h>
1719
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
@@ -418,13 +420,13 @@ - (void)reloadDataInitiallyIfNeeded
418420
- (NSInteger)numberOfItemsInSection:(NSInteger)section
419421
{
420422
[self reloadDataInitiallyIfNeeded];
421-
return [self.dataController numberOfRowsInSection:section];
423+
return [self.dataController.pendingMap numberOfItemsInSection:section];
422424
}
423425

424426
- (NSInteger)numberOfSections
425427
{
426428
[self reloadDataInitiallyIfNeeded];
427-
return [self.dataController numberOfSections];
429+
return self.dataController.pendingMap.numberOfSections;
428430
}
429431

430432
- (NSArray<__kindof ASCellNode *> *)visibleNodes
@@ -436,12 +438,12 @@ - (NSInteger)numberOfSections
436438
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
437439
{
438440
[self reloadDataInitiallyIfNeeded];
439-
return [self.dataController nodeAtIndexPath:indexPath];
441+
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].node;
440442
}
441443

442444
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
443445
{
444-
return [self.dataController indexPathForNode:cellNode];
446+
return [self.dataController.pendingMap indexPathForElement:cellNode.collectionElement];
445447
}
446448

447449
- (NSArray<NSIndexPath *> *)indexPathsForVisibleItems
@@ -484,7 +486,7 @@ - (nullable UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPa
484486
- (id<ASSectionContext>)contextForSection:(NSInteger)section
485487
{
486488
ASDisplayNodeAssertMainThread();
487-
return [self.dataController contextForSection:section];
489+
return [self.dataController.pendingMap contextForSection:section];
488490
}
489491

490492
#pragma mark - Editing

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
#import <AsyncDisplayKit/ASBatchFetching.h>
1414
#import <AsyncDisplayKit/ASDelegateProxy.h>
1515
#import <AsyncDisplayKit/ASCellNode+Internal.h>
16+
#import <AsyncDisplayKit/ASCollectionElement.h>
1617
#import <AsyncDisplayKit/ASCollectionInternal.h>
1718
#import <AsyncDisplayKit/ASCollectionViewLayoutController.h>
1819
#import <AsyncDisplayKit/ASCollectionViewFlowLayoutInspector.h>
1920
#import <AsyncDisplayKit/ASDataController.h>
2021
#import <AsyncDisplayKit/ASDisplayNodeExtras.h>
2122
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
23+
#import <AsyncDisplayKit/ASElementMap.h>
2224
#import <AsyncDisplayKit/ASInternalHelpers.h>
2325
#import <AsyncDisplayKit/UICollectionViewLayout+ASConvenience.h>
2426
#import <AsyncDisplayKit/ASRangeController.h>
@@ -604,14 +606,9 @@ - (CGSize)calculatedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
604606
return [[self nodeForItemAtIndexPath:indexPath] calculatedSize];
605607
}
606608

607-
- (NSArray<NSArray <ASCellNode *> *> *)completedNodes
608-
{
609-
return [_dataController completedNodes];
610-
}
611-
612609
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
613610
{
614-
return [_dataController nodeAtCompletedIndexPath:indexPath];
611+
return [_dataController.visibleMap elementForItemAtIndexPath:indexPath].node;
615612
}
616613

617614
- (NSIndexPath *)convertIndexPathFromCollectionNode:(NSIndexPath *)indexPath waitingIfNeeded:(BOOL)wait
@@ -625,11 +622,10 @@ - (NSIndexPath *)convertIndexPathFromCollectionNode:(NSIndexPath *)indexPath wai
625622
if (indexPath.item == NSNotFound) {
626623
return indexPath;
627624
} else {
628-
ASCellNode *node = [_dataController nodeAtIndexPath:indexPath];
629-
NSIndexPath *viewIndexPath = [self indexPathForNode:node];
625+
NSIndexPath *viewIndexPath = [_dataController.visibleMap convertIndexPath:indexPath fromMap:_dataController.pendingMap];
630626
if (viewIndexPath == nil && wait) {
631627
[self waitUntilAllUpdatesAreCommitted];
632-
viewIndexPath = [self indexPathForNode:node];
628+
return [self convertIndexPathFromCollectionNode:indexPath waitingIfNeeded:NO];
633629
}
634630
return viewIndexPath;
635631
}
@@ -671,8 +667,7 @@ - (NSIndexPath *)convertIndexPathToCollectionNode:(NSIndexPath *)indexPath
671667
if (indexPath.item == NSNotFound) {
672668
return indexPath;
673669
} else {
674-
ASCellNode *node = [self nodeForItemAtIndexPath:indexPath];
675-
return [_dataController indexPathForNode:node];
670+
return [_dataController.visibleMap convertIndexPath:indexPath fromMap:_dataController.pendingMap];
676671
}
677672
}
678673

@@ -695,12 +690,12 @@ - (NSIndexPath *)convertIndexPathToCollectionNode:(NSIndexPath *)indexPath
695690

696691
- (ASCellNode *)supplementaryNodeForElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
697692
{
698-
return [_dataController supplementaryNodeOfKind:elementKind atIndexPath:indexPath];
693+
return [_dataController.visibleMap supplementaryElementOfKind:elementKind atIndexPath:indexPath].node;
699694
}
700695

701696
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
702697
{
703-
return [self validateIndexPath:[_dataController completedIndexPathForNode:cellNode]];
698+
return [_dataController.visibleMap indexPathForElement:cellNode.collectionElement];
704699
}
705700

706701
- (NSArray *)visibleNodes
@@ -835,7 +830,7 @@ - (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection
835830
- (id<ASSectionContext>)contextForSection:(NSInteger)section
836831
{
837832
ASDisplayNodeAssertMainThread();
838-
return [_dataController contextForSection:section];
833+
return [_dataController.visibleMap contextForSection:section];
839834
}
840835

841836
- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths
@@ -883,12 +878,12 @@ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
883878
[self _scheduleCheckForBatchFetchingForNumberOfChanges:1];
884879
_superIsPendingDataLoad = NO;
885880
}
886-
return [_dataController completedNumberOfSections];
881+
return _dataController.visibleMap.numberOfSections;
887882
}
888883

889884
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
890885
{
891-
return [_dataController completedNumberOfRowsInSection:section];
886+
return [_dataController.visibleMap numberOfItemsInSection:section];
892887
}
893888

894889
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
@@ -927,7 +922,7 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
927922
}
928923

929924
UICollectionReusableView *view = nil;
930-
ASCellNode *node = [_dataController supplementaryNodeOfKind:kind atIndexPath:indexPath];
925+
ASCellNode *node = [_dataController.visibleMap supplementaryElementOfKind:kind atIndexPath:indexPath].node;
931926

932927
BOOL shouldDequeueExternally = _asyncDataSourceFlags.interopViewForSupplementaryElement && (_asyncDataSourceFlags.interopAlwaysDequeue || node.shouldUseUIKitCell);
933928
if (shouldDequeueExternally) {
@@ -1653,6 +1648,11 @@ - (NSArray *)visibleNodeIndexPathsForRangeController:(ASRangeController *)rangeC
16531648
return isZeroSized ? @[] : [self indexPathsForVisibleItems];
16541649
}
16551650

1651+
- (ASElementMap *)elementMapForRangeController:(ASRangeController *)rangeController
1652+
{
1653+
return _dataController.visibleMap;
1654+
}
1655+
16561656
- (ASScrollDirection)scrollDirectionForRangeController:(ASRangeController *)rangeController
16571657
{
16581658
return self.scrollDirection;
@@ -1669,11 +1669,6 @@ - (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeC
16691669
return ASInterfaceStateForDisplayNode(self.collectionNode, self.window);
16701670
}
16711671

1672-
- (ASDisplayNode *)rangeController:(ASRangeController *)rangeController nodeAtIndexPath:(NSIndexPath *)indexPath
1673-
{
1674-
return [self nodeForItemAtIndexPath:indexPath];
1675-
}
1676-
16771672
- (NSString *)nameForRangeControllerDataSource
16781673
{
16791674
return self.asyncDataSource ? NSStringFromClass([self.asyncDataSource class]) : NSStringFromClass([self class]);

AsyncDisplayKit/ASTableNode.mm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//
1212

1313
#import <AsyncDisplayKit/ASTableNode.h>
14+
#import <AsyncDisplayKit/ASCollectionElement.h>
15+
#import <AsyncDisplayKit/ASElementMap.h>
1416
#import <AsyncDisplayKit/ASTableViewInternal.h>
1517
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
1618
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
@@ -438,14 +440,14 @@ - (NSInteger)numberOfRowsInSection:(NSInteger)section
438440
{
439441
ASDisplayNodeAssertMainThread();
440442
[self reloadDataInitiallyIfNeeded];
441-
return [self.dataController numberOfRowsInSection:section];
443+
return [self.dataController.pendingMap numberOfItemsInSection:section];
442444
}
443445

444446
- (NSInteger)numberOfSections
445447
{
446448
ASDisplayNodeAssertMainThread();
447449
[self reloadDataInitiallyIfNeeded];
448-
return [self.dataController numberOfSections];
450+
return [self.dataController.pendingMap numberOfSections];
449451
}
450452

451453
- (NSArray<__kindof ASCellNode *> *)visibleNodes
@@ -456,13 +458,13 @@ - (NSInteger)numberOfSections
456458

457459
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
458460
{
459-
return [self.dataController indexPathForNode:cellNode];
461+
return [self.dataController.pendingMap indexPathForElement:cellNode.collectionElement];
460462
}
461463

462464
- (ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath
463465
{
464466
[self reloadDataInitiallyIfNeeded];
465-
return [self.dataController nodeAtIndexPath:indexPath];
467+
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].node;
466468
}
467469

468470
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath

0 commit comments

Comments
 (0)