From 6565b8348d8f9ff719c44580ef914d14a47aabdd Mon Sep 17 00:00:00 2001 From: Hannah Trosi Date: Thu, 17 Nov 2016 16:46:07 +0900 Subject: [PATCH] collectionView --- AsyncDisplayKit/ASCollectionView.h | 36 +++++++++---------- AsyncDisplayKit/ASCollectionView.mm | 16 +++++++-- AsyncDisplayKit/ASPagerNode.m | 1 + AsyncDisplayKit/ASTableView.h | 6 ++-- AsyncDisplayKit/ASTableView.mm | 14 ++++++++ .../Private/ASCollectionView+Undeprecated.h | 18 ++++++++++ ...ASCollectionViewFlowLayoutInspectorTests.m | 1 + 7 files changed, 69 insertions(+), 23 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index 88a1aaadfa..1f6fb93c8d 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -38,24 +38,6 @@ NS_ASSUME_NONNULL_BEGIN */ @interface ASCollectionView : UICollectionView -/** - * The object that acts as the asynchronous delegate of the collection view - * - * @discussion The delegate must adopt the ASCollectionDelegate protocol. The collection view maintains a weak reference to the delegate object. - * - * The delegate object is responsible for providing size constraints for nodes and indicating whether batch fetching should begin. - */ -@property (nonatomic, weak) id asyncDelegate; - -/** - * The object that acts as the asynchronous data source of the collection view - * - * @discussion The datasource must adopt the ASCollectionDataSource protocol. The collection view maintains a weak reference to the datasource object. - * - * The datasource object is responsible for providing nodes or node creation blocks to the collection view. - */ -@property (nonatomic, weak) id asyncDataSource; - /** * Returns the corresponding ASCollectionNode * @@ -138,6 +120,24 @@ NS_ASSUME_NONNULL_BEGIN @interface ASCollectionView (Deprecated) +/** + * The object that acts as the asynchronous delegate of the collection view + * + * @discussion The delegate must adopt the ASCollectionDelegate protocol. The collection view maintains a weak reference to the delegate object. + * + * The delegate object is responsible for providing size constraints for nodes and indicating whether batch fetching should begin. + */ +@property (nonatomic, weak) id asyncDelegate ASDISPLAYNODE_DEPRECATED_MSG("Please use ASCollectionNode's .delegate property instead."); + +/** + * The object that acts as the asynchronous data source of the collection view + * + * @discussion The datasource must adopt the ASCollectionDataSource protocol. The collection view maintains a weak reference to the datasource object. + * + * The datasource object is responsible for providing nodes or node creation blocks to the collection view. + */ +@property (nonatomic, weak) id asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Please use ASCollectionNode's .dataSource property instead."); + /** * Initializes an ASCollectionView * diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index f80f476c2c..cd5e3697a7 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -224,8 +224,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; @end @implementation ASCollectionView -@synthesize asyncDelegate = _asyncDelegate; -@synthesize asyncDataSource = _asyncDataSource; +{ + id _asyncDelegate; + id _asyncDataSource; +} // Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASCollectionNode. + (Class)layerClass @@ -363,6 +365,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; } } +- (id)asyncDataSource +{ + return _asyncDataSource; +} + - (void)setAsyncDataSource:(id)asyncDataSource { // Note: It's common to check if the value hasn't changed and short-circuit but we aren't doing that here to handle @@ -410,6 +417,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; } } +- (id)asyncDelegate +{ + return _asyncDelegate; +} + - (void)setAsyncDelegate:(id)asyncDelegate { // Note: It's common to check if the value hasn't changed and short-circuit but we aren't doing that here to handle diff --git a/AsyncDisplayKit/ASPagerNode.m b/AsyncDisplayKit/ASPagerNode.m index 21310e754e..4e8db5d654 100644 --- a/AsyncDisplayKit/ASPagerNode.m +++ b/AsyncDisplayKit/ASPagerNode.m @@ -16,6 +16,7 @@ #import "ASPagerFlowLayout.h" #import "ASAssert.h" #import "ASCellNode.h" +#import "ASCollectionView+Undeprecated.h" @interface ASPagerNode () { diff --git a/AsyncDisplayKit/ASTableView.h b/AsyncDisplayKit/ASTableView.h index f390a380e8..b932edc873 100644 --- a/AsyncDisplayKit/ASTableView.h +++ b/AsyncDisplayKit/ASTableView.h @@ -38,9 +38,6 @@ NS_ASSUME_NONNULL_BEGIN /// The corresponding table node, or nil if one does not exist. @property (nonatomic, weak, readonly) ASTableNode *tableNode; -@property (nonatomic, weak) id asyncDelegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode's .delegate property instead."); -@property (nonatomic, weak) id asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode .dataSource property instead."); - /** * Retrieves the node for the row at the given index path. */ @@ -66,6 +63,9 @@ NS_ASSUME_NONNULL_BEGIN @interface ASTableView (Deprecated) +@property (nonatomic, weak) id asyncDelegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode's .delegate property instead."); +@property (nonatomic, weak) id asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode .dataSource property instead."); + /** * Initializer. * diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index a3b75fb5b4..6e78d68110 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -197,6 +197,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; @end @implementation ASTableView +{ + id _asyncDelegate; + id _asyncDataSource; +} // Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASTableNode. + (Class)layerClass @@ -299,6 +303,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; ASDisplayNodeAssert(delegate == nil, @"ASTableView uses asyncDelegate, not UITableView's delegate property."); } +- (id)asyncDataSource +{ + return _asyncDataSource; +} + - (void)setAsyncDataSource:(id)asyncDataSource { // Note: It's common to check if the value hasn't changed and short-circuit but we aren't doing that here to handle @@ -338,6 +347,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; super.dataSource = (id)_proxyDataSource; } +- (id)asyncDelegate +{ + return _asyncDelegate; +} + - (void)setAsyncDelegate:(id)asyncDelegate { // Note: It's common to check if the value hasn't changed and short-circuit but we aren't doing that here to handle diff --git a/AsyncDisplayKit/Private/ASCollectionView+Undeprecated.h b/AsyncDisplayKit/Private/ASCollectionView+Undeprecated.h index b633d65b68..44683e8359 100644 --- a/AsyncDisplayKit/Private/ASCollectionView+Undeprecated.h +++ b/AsyncDisplayKit/Private/ASCollectionView+Undeprecated.h @@ -19,6 +19,24 @@ NS_ASSUME_NONNULL_BEGIN */ @interface ASCollectionView (Undeprecated) +/** + * The object that acts as the asynchronous delegate of the collection view + * + * @discussion The delegate must adopt the ASCollectionDelegate protocol. The collection view maintains a weak reference to the delegate object. + * + * The delegate object is responsible for providing size constraints for nodes and indicating whether batch fetching should begin. + */ +@property (nonatomic, weak) id asyncDelegate; + +/** + * The object that acts as the asynchronous data source of the collection view + * + * @discussion The datasource must adopt the ASCollectionDataSource protocol. The collection view maintains a weak reference to the datasource object. + * + * The datasource object is responsible for providing nodes or node creation blocks to the collection view. + */ +@property (nonatomic, weak) id asyncDataSource; + /** * Initializes an ASCollectionView * diff --git a/AsyncDisplayKitTests/ASCollectionViewFlowLayoutInspectorTests.m b/AsyncDisplayKitTests/ASCollectionViewFlowLayoutInspectorTests.m index 443e1d7534..5c1091bfd6 100644 --- a/AsyncDisplayKitTests/ASCollectionViewFlowLayoutInspectorTests.m +++ b/AsyncDisplayKitTests/ASCollectionViewFlowLayoutInspectorTests.m @@ -16,6 +16,7 @@ #import "ASCollectionNode.h" #import "ASCollectionViewFlowLayoutInspector.h" #import "ASCellNode.h" +#import "ASCollectionView+Undeprecated.h" @interface ASCollectionView (Private)