Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 5e72daa

Browse files
committed
Pass node along in didEndDisplayingNode method
1 parent 516e1f1 commit 5e72daa

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

AsyncDisplayKit/ASCollectionView.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ NS_ASSUME_NONNULL_BEGIN
376376
@optional
377377

378378
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
379-
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
379+
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath;
380380

381381
/**
382382
* Receive a message that the collectionView is near the end of its data set and more data should be fetched if
@@ -406,6 +406,11 @@ NS_ASSUME_NONNULL_BEGIN
406406
*/
407407
- (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView;
408408

409+
/**
410+
* Use `collectionView:didEndDisplayingNode:forItemAtIndexPath:` instead.
411+
*/
412+
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
413+
409414
@end
410415

411416
/**

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,18 @@ - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICol
570570
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
571571
{
572572
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
573-
573+
574+
if ([_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNode:forItemAtIndexPath:)]) {
575+
ASCellNode *node = ((_ASCollectionViewCell *)cell).node;
576+
ASDisplayNodeAssertNotNil(node, @"Expected node associated with removed cell not to be nil.");
577+
[_asyncDelegate collectionView:self didEndDisplayingNode:node forItemAtIndexPath:indexPath];
578+
}
579+
#pragma clang diagnostic push
580+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
574581
if ([_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNodeForItemAtIndexPath:)]) {
575582
[_asyncDelegate collectionView:self didEndDisplayingNodeForItemAtIndexPath:indexPath];
576583
}
584+
#pragma clang diagnostic pop
577585
}
578586

579587
- (void)layoutSubviews

AsyncDisplayKit/ASTableView.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ NS_ASSUME_NONNULL_BEGIN
336336
@optional
337337

338338
- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath;
339-
- (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath;
339+
340+
- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath;
340341

341342
/**
342343
* Receive a message that the tableView is near the end of its data set and more data should be fetched if necessary.
@@ -365,6 +366,11 @@ NS_ASSUME_NONNULL_BEGIN
365366
*/
366367
- (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView;
367368

369+
/**
370+
* Use `tableView:didEndDisplayNode:forRowAtIndexPath` instead.
371+
*/
372+
- (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
373+
368374
@end
369375

370376
@protocol ASTableViewDelegate <ASTableDelegate>

AsyncDisplayKit/ASTableView.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,18 @@ - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell
598598

599599
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
600600

601+
if ([_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNode:forRowAtIndexPath:)]) {
602+
ASCellNode *node = ((_ASTableViewCell *)cell).node;
603+
ASDisplayNodeAssertNotNil(node, @"Expected node associated with removed cell not to be nil.");
604+
[_asyncDelegate tableView:self didEndDisplayingNode:node forRowAtIndexPath:indexPath];
605+
}
606+
607+
#pragma clang diagnostic push
608+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
601609
if ([_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNodeForRowAtIndexPath:)]) {
602610
[_asyncDelegate tableView:self didEndDisplayingNodeForRowAtIndexPath:indexPath];
603611
}
612+
#pragma clang diagnostic pop
604613
}
605614

606615

0 commit comments

Comments
 (0)