From 9873f4bd7df1341e215e818f7d6f3d4f46813509 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Mon, 20 Jun 2016 16:40:10 -0700 Subject: [PATCH 1/3] Deprecate willDisplayNode:/didEndDisplayingNode: methods --- AsyncDisplayKit/ASCollectionView.h | 48 ++++++++++++++++++++--------- AsyncDisplayKit/ASCollectionView.mm | 6 ++++ AsyncDisplayKit/ASTableView.h | 48 ++++++++++++++++++++--------- AsyncDisplayKit/ASTableView.mm | 6 ++++ 4 files changed, 80 insertions(+), 28 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index fa39c62bd6..1ee140f124 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -430,19 +430,6 @@ NS_ASSUME_NONNULL_BEGIN @optional -- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath; - -/** - * Informs the delegate that the collection view did remove the provided node from the view hierarchy. - * This may be caused by the node scrolling out of view, or by deleting the item - * or its containing section with @c deleteItemsAtIndexPaths: or @c deleteSections: . - * - * @param collectionView The sender. - * @param node The node which was removed from the view hierarchy. - * @param indexPath The index path at which the node was located before it was removed. - */ -- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath; - /** * Receive a message that the collectionView is near the end of its data set and more data should be fetched if * necessary. @@ -475,10 +462,43 @@ NS_ASSUME_NONNULL_BEGIN * Informs the delegate that the collection view did remove the node which was previously * at the given index path from the view hierarchy. * - * This method is deprecated. Use @c collectionView:didEndDisplayingNode:forItemAtIndexPath: instead. + * @warning AsyncDisplayKit processes table view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + * + * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. */ - (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; +/** + * Informs the delegate that the collection view will add the node + * at the given index path to the view hierarchy. + * + * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + * + * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. + */ +- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; + +/** + * Informs the delegate that the collection view did remove the provided node from the view hierarchy. + * This may be caused by the node scrolling out of view, or by deleting the item + * or its containing section with @c deleteItemsAtIndexPaths: or @c deleteSections: . + * + * @param collectionView The sender. + * @param node The node which was removed from the view hierarchy. + * @param indexPath The index path at which the node was located before it was removed. + * + * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + * + * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. + */ +- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; + @end /** diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 821e21ddca..e0321a15cd 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -605,9 +605,12 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; ASCellNode *cellNode = [cell node]; cellNode.scrollView = collectionView; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath) { [_asyncDelegate collectionView:self willDisplayNodeForItemAtIndexPath:indexPath]; } +#pragma clang diagnostic pop [_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection]; @@ -625,10 +628,13 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; ASCellNode *cellNode = [cell node]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPath) { ASDisplayNodeAssertNotNil(cellNode, @"Expected node associated with removed cell not to be nil."); [_asyncDelegate collectionView:self didEndDisplayingNode:cellNode forItemAtIndexPath:indexPath]; } +#pragma clang diagnostic pop if ([_cellsForVisibilityUpdates containsObject:cell]) { [_cellsForVisibilityUpdates removeObject:cell]; diff --git a/AsyncDisplayKit/ASTableView.h b/AsyncDisplayKit/ASTableView.h index 4a6d678025..a7971ee420 100644 --- a/AsyncDisplayKit/ASTableView.h +++ b/AsyncDisplayKit/ASTableView.h @@ -390,19 +390,6 @@ NS_ASSUME_NONNULL_BEGIN @optional -- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath; - -/** - * Informs the delegate that the table view did remove the provided node from the view hierarchy. - * This may be caused by the node scrolling out of view, or by deleting the row - * or its containing section with @c deleteRowsAtIndexPaths:withRowAnimation: or @c deleteSections:withRowAnimation: . - * - * @param tableView The sender. - * @param node The node which was removed from the view hierarchy. - * @param indexPath The index path at which the node was located before the removal. - */ -- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath; - /** * Receive a message that the tableView is near the end of its data set and more data should be fetched if necessary. * @@ -430,14 +417,47 @@ NS_ASSUME_NONNULL_BEGIN */ - (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView; +/** + * Informs the delegate that the table view did remove the provided node from the view hierarchy. + * This may be caused by the node scrolling out of view, or by deleting the row + * or its containing section with @c deleteRowsAtIndexPaths:withRowAnimation: or @c deleteSections:withRowAnimation: . + * + * @param tableView The sender. + * @param node The node which was removed from the view hierarchy. + * @param indexPath The index path at which the node was located before the removal. + * + * @warning AsyncDisplayKit processes table view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + * + * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. + */ +- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; + /** * Informs the delegate that the table view did remove the node which was previously * at the given index path from the view hierarchy. * - * This method is deprecated. Use @c tableView:didEndDisplayingNode:forRowAtIndexPath: instead. + * @warning AsyncDisplayKit processes table view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + * + * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. */ - (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; +/** + * Informs the delegate that the table view will add the node + * at the given index path to the view hierarchy. + * + * @warning AsyncDisplayKit processes table view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + * + * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. + */ +- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; + @end @protocol ASTableViewDelegate diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index b8a174bbdd..a0bfd98b03 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -623,9 +623,12 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; ASCellNode *cellNode = [cell node]; cellNode.scrollView = tableView; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath) { [_asyncDelegate tableView:self willDisplayNodeForRowAtIndexPath:indexPath]; } +#pragma clang diagnostic pop [_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:[self scrollDirection]]; @@ -648,10 +651,13 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; [_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:[self scrollDirection]]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPath) { ASDisplayNodeAssertNotNil(cellNode, @"Expected node associated with removed cell not to be nil."); [_asyncDelegate tableView:self didEndDisplayingNode:cellNode forRowAtIndexPath:indexPath]; } +#pragma clang diagnostic pop if ([_cellsForVisibilityUpdates containsObject:cell]) { [_cellsForVisibilityUpdates removeObject:cell]; From c14bbf6005b29043a024468d5b26dd3dc6bf2334 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Tue, 21 Jun 2016 09:16:54 -0700 Subject: [PATCH 2/3] Undeprecate the methods. Just inform users about the index path issue --- AsyncDisplayKit/ASCollectionView.h | 61 +++++++++++++++--------------- AsyncDisplayKit/ASTableView.h | 55 ++++++++++++--------------- 2 files changed, 55 insertions(+), 61 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index 1ee140f124..a2d5e2ec44 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -430,6 +430,34 @@ NS_ASSUME_NONNULL_BEGIN @optional +/** + * Informs the delegate that the collection view will add the node + * at the given index path to the view hierarchy. + * + * @param collectionView The sender. + * @param indexPath The index path of the item that will be displayed. + * + * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + */ +- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath; + +/** + * Informs the delegate that the collection view did remove the provided node from the view hierarchy. + * This may be caused by the node scrolling out of view, or by deleting the item + * or its containing section with @c deleteItemsAtIndexPaths: or @c deleteSections: . + * + * @param collectionView The sender. + * @param node The node which was removed from the view hierarchy. + * @param indexPath The index path at which the node was located before it was removed. + * + * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + */ +- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath; + /** * Receive a message that the collectionView is near the end of its data set and more data should be fetched if * necessary. @@ -462,43 +490,14 @@ NS_ASSUME_NONNULL_BEGIN * Informs the delegate that the collection view did remove the node which was previously * at the given index path from the view hierarchy. * - * @warning AsyncDisplayKit processes table view edits asynchronously. The index path + * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path * passed into this method may not correspond to the same item in your data source * if your data source has been updated since the last edit was processed. * - * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. + * This method is deprecated. Use @c collectionView:didEndDisplayingNode:forItemAtIndexPath: instead. */ - (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; -/** - * Informs the delegate that the collection view will add the node - * at the given index path to the view hierarchy. - * - * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path - * passed into this method may not correspond to the same item in your data source - * if your data source has been updated since the last edit was processed. - * - * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. - */ -- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; - -/** - * Informs the delegate that the collection view did remove the provided node from the view hierarchy. - * This may be caused by the node scrolling out of view, or by deleting the item - * or its containing section with @c deleteItemsAtIndexPaths: or @c deleteSections: . - * - * @param collectionView The sender. - * @param node The node which was removed from the view hierarchy. - * @param indexPath The index path at which the node was located before it was removed. - * - * @warning AsyncDisplayKit processes collection view edits asynchronously. The index path - * passed into this method may not correspond to the same item in your data source - * if your data source has been updated since the last edit was processed. - * - * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. - */ -- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; - @end /** diff --git a/AsyncDisplayKit/ASTableView.h b/AsyncDisplayKit/ASTableView.h index a7971ee420..4ab4877121 100644 --- a/AsyncDisplayKit/ASTableView.h +++ b/AsyncDisplayKit/ASTableView.h @@ -390,6 +390,30 @@ NS_ASSUME_NONNULL_BEGIN @optional +/** + * Informs the delegate that the table view will add the node + * at the given index path to the view hierarchy. + * + * @param tableView The sender. + * @param indexPath The index path of the row that will be displayed. + * + * @warning AsyncDisplayKit processes table view edits asynchronously. The index path + * passed into this method may not correspond to the same item in your data source + * if your data source has been updated since the last edit was processed. + */ +- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath; + +/** + * Informs the delegate that the table view did remove the provided node from the view hierarchy. + * This may be caused by the node scrolling out of view, or by deleting the row + * or its containing section with @c deleteRowsAtIndexPaths:withRowAnimation: or @c deleteSections:withRowAnimation: . + * + * @param tableView The sender. + * @param node The node which was removed from the view hierarchy. + * @param indexPath The index path at which the node was located before the removal. + */ +- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath; + /** * Receive a message that the tableView is near the end of its data set and more data should be fetched if necessary. * @@ -417,23 +441,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView; -/** - * Informs the delegate that the table view did remove the provided node from the view hierarchy. - * This may be caused by the node scrolling out of view, or by deleting the row - * or its containing section with @c deleteRowsAtIndexPaths:withRowAnimation: or @c deleteSections:withRowAnimation: . - * - * @param tableView The sender. - * @param node The node which was removed from the view hierarchy. - * @param indexPath The index path at which the node was located before the removal. - * - * @warning AsyncDisplayKit processes table view edits asynchronously. The index path - * passed into this method may not correspond to the same item in your data source - * if your data source has been updated since the last edit was processed. - * - * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. - */ -- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; - /** * Informs the delegate that the table view did remove the node which was previously * at the given index path from the view hierarchy. @@ -442,22 +449,10 @@ NS_ASSUME_NONNULL_BEGIN * passed into this method may not correspond to the same item in your data source * if your data source has been updated since the last edit was processed. * - * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. + * This method is deprecated. Use @c tableView:didEndDisplayingNode:forRowAtIndexPath: instead. */ - (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; -/** - * Informs the delegate that the table view will add the node - * at the given index path to the view hierarchy. - * - * @warning AsyncDisplayKit processes table view edits asynchronously. The index path - * passed into this method may not correspond to the same item in your data source - * if your data source has been updated since the last edit was processed. - * - * This method is deprecated. Use @c visibleStateDidChange: on the cell node instead. - */ -- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED; - @end @protocol ASTableViewDelegate From fcb69382243fb37f3183c7ec3ef05bb2cd376808 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Tue, 21 Jun 2016 09:20:40 -0700 Subject: [PATCH 3/3] Revert deprecated method warning suppression --- AsyncDisplayKit/ASCollectionView.mm | 6 ------ AsyncDisplayKit/ASTableView.mm | 6 ------ 2 files changed, 12 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index e0321a15cd..821e21ddca 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -605,12 +605,9 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; ASCellNode *cellNode = [cell node]; cellNode.scrollView = collectionView; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath) { [_asyncDelegate collectionView:self willDisplayNodeForItemAtIndexPath:indexPath]; } -#pragma clang diagnostic pop [_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection]; @@ -628,13 +625,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; ASCellNode *cellNode = [cell node]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPath) { ASDisplayNodeAssertNotNil(cellNode, @"Expected node associated with removed cell not to be nil."); [_asyncDelegate collectionView:self didEndDisplayingNode:cellNode forItemAtIndexPath:indexPath]; } -#pragma clang diagnostic pop if ([_cellsForVisibilityUpdates containsObject:cell]) { [_cellsForVisibilityUpdates removeObject:cell]; diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index a0bfd98b03..b8a174bbdd 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -623,12 +623,9 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; ASCellNode *cellNode = [cell node]; cellNode.scrollView = tableView; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath) { [_asyncDelegate tableView:self willDisplayNodeForRowAtIndexPath:indexPath]; } -#pragma clang diagnostic pop [_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:[self scrollDirection]]; @@ -651,13 +648,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; [_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:[self scrollDirection]]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (_asyncDelegateFlags.asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPath) { ASDisplayNodeAssertNotNil(cellNode, @"Expected node associated with removed cell not to be nil."); [_asyncDelegate tableView:self didEndDisplayingNode:cellNode forRowAtIndexPath:indexPath]; } -#pragma clang diagnostic pop if ([_cellsForVisibilityUpdates containsObject:cell]) { [_cellsForVisibilityUpdates removeObject:cell];