From 298b9a2be7bc6f52755538fb9eb6a9a88cc55312 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Wed, 20 Apr 2016 12:57:56 -0700 Subject: [PATCH 1/2] Fix ASPagerNode data source and delegate inconsistencies - Change ASPagerNodeDataSource -> ASPagerDataSource - Add ASPagerDelegate --- AsyncDisplayKit/ASCollectionView.h | 2 +- AsyncDisplayKit/ASPagerNode.h | 22 ++++++++++++++-------- AsyncDisplayKit/ASPagerNode.m | 6 +++--- AsyncDisplayKit/Details/ASDelegateProxy.m | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index 99a4bd0548..e6f43bec3c 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -342,7 +342,7 @@ NS_ASSUME_NONNULL_BEGIN * This is a node-based UICollectionViewDataSource. */ #define ASCollectionViewDataSource ASCollectionDataSource -@protocol ASCollectionDataSource +@protocol ASCollectionDataSource @optional diff --git a/AsyncDisplayKit/ASPagerNode.h b/AsyncDisplayKit/ASPagerNode.h index 7b64836928..5adb5ab9fb 100644 --- a/AsyncDisplayKit/ASPagerNode.h +++ b/AsyncDisplayKit/ASPagerNode.h @@ -11,7 +11,8 @@ @class ASPagerNode; @class ASPagerFlowLayout; -@protocol ASPagerNodeDataSource +#define ASPagerNodeDataSource ASPagerDataSource +@protocol ASPagerDataSource /** * This method replaces -collectionView:numberOfItemsInSection: @@ -65,25 +66,30 @@ @end +@protocol ASPagerDelegate + +@end + @interface ASPagerNode : ASCollectionNode -// Configures a default horizontal, paging flow layout with 0 inter-item spacing. +/// Configures a default horizontal, paging flow layout with 0 inter-item spacing. - (instancetype)init; -// Initializer with custom-configured flow layout properties. +/// Initializer with custom-configured flow layout properties. - (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout; -// Data Source is required, and uses a different protocol from ASCollectionNode. -- (void)setDataSource:(id )dataSource; -- (id )dataSource; +/// Data Source is required, and uses a different protocol from ASCollectionNode. +- (void)setDataSource:(id )dataSource; +- (id )dataSource; // Delegate is optional, and uses the same protocol as ASCollectionNode. // This includes UIScrollViewDelegate as well as most methods from UICollectionViewDelegate, like willDisplay... -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id delegate; -// The underlying ASCollectionView object. +/// The underlying ASCollectionView object. @property (nonatomic, readonly) ASCollectionView *view; +/// Scroll the contents of the receiver to ensure that the page is visible. - (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated; @end diff --git a/AsyncDisplayKit/ASPagerNode.m b/AsyncDisplayKit/ASPagerNode.m index 52e33bc8fa..ac8cbc593f 100644 --- a/AsyncDisplayKit/ASPagerNode.m +++ b/AsyncDisplayKit/ASPagerNode.m @@ -16,7 +16,7 @@ { ASPagerFlowLayout *_flowLayout; ASPagerNodeProxy *_proxy; - __weak id _pagerDataSource; + __weak id _pagerDataSource; BOOL _pagerDataSourceImplementsNodeBlockAtIndex; BOOL _pagerDataSourceImplementsConstrainedSizeForNode; } @@ -111,12 +111,12 @@ #pragma mark - Data Source Proxy -- (id )dataSource +- (id )dataSource { return _pagerDataSource; } -- (void)setDataSource:(id )pagerDataSource +- (void)setDataSource:(id )pagerDataSource { if (pagerDataSource != _pagerDataSource) { _pagerDataSource = pagerDataSource; diff --git a/AsyncDisplayKit/Details/ASDelegateProxy.m b/AsyncDisplayKit/Details/ASDelegateProxy.m index b4f6977525..9e2e901347 100644 --- a/AsyncDisplayKit/Details/ASDelegateProxy.m +++ b/AsyncDisplayKit/Details/ASDelegateProxy.m @@ -77,7 +77,7 @@ - (BOOL)interceptsSelector:(SEL)selector { return ( - // handled by ASPagerNodeDataSource node<->cell machinery + // handled by ASPagerDataSource node<->cell machinery selector == @selector(collectionView:nodeForItemAtIndexPath:) || selector == @selector(collectionView:nodeBlockForItemAtIndexPath:) || selector == @selector(collectionView:numberOfItemsInSection:) || From cad221007e0e898132c82d0445625a1da016ee19 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Wed, 20 Apr 2016 13:12:19 -0700 Subject: [PATCH 2/2] Remove extending NSObject protocol in ASPagerDelegate as ASCollectionDelegate already extends it --- AsyncDisplayKit/ASPagerNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASPagerNode.h b/AsyncDisplayKit/ASPagerNode.h index 5adb5ab9fb..481ceaf1c6 100644 --- a/AsyncDisplayKit/ASPagerNode.h +++ b/AsyncDisplayKit/ASPagerNode.h @@ -66,7 +66,7 @@ @end -@protocol ASPagerDelegate +@protocol ASPagerDelegate @end