Skip to content

Commit

Permalink
collectionView
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahmbanana committed Nov 17, 2016
1 parent c9143fb commit 6565b83
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 23 deletions.
36 changes: 18 additions & 18 deletions AsyncDisplayKit/ASCollectionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ASCollectionDelegate> 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<ASCollectionDataSource> asyncDataSource;

/**
* Returns the corresponding ASCollectionNode
*
Expand Down Expand Up @@ -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<ASCollectionDelegate> 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<ASCollectionDataSource> asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Please use ASCollectionNode's .dataSource property instead.");

/**
* Initializes an ASCollectionView
*
Expand Down
16 changes: 14 additions & 2 deletions AsyncDisplayKit/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ - (instancetype)_initWithCollectionView:(ASCollectionView *)collectionView;
@end

@implementation ASCollectionView
@synthesize asyncDelegate = _asyncDelegate;
@synthesize asyncDataSource = _asyncDataSource;
{
id<ASCollectionDelegate> _asyncDelegate;
id<ASCollectionDataSource> _asyncDataSource;
}

// Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASCollectionNode.
+ (Class)layerClass
Expand Down Expand Up @@ -363,6 +365,11 @@ - (void)proxyTargetHasDeallocated:(ASDelegateProxy *)proxy
}
}

- (id<ASCollectionDataSource>)asyncDataSource
{
return _asyncDataSource;
}

- (void)setAsyncDataSource:(id<ASCollectionDataSource>)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
Expand Down Expand Up @@ -410,6 +417,11 @@ - (void)setAsyncDataSource:(id<ASCollectionDataSource>)asyncDataSource
}
}

- (id<ASCollectionDelegate>)asyncDelegate
{
return _asyncDelegate;
}

- (void)setAsyncDelegate:(id<ASCollectionDelegate>)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
Expand Down
1 change: 1 addition & 0 deletions AsyncDisplayKit/ASPagerNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#import "ASPagerFlowLayout.h"
#import "ASAssert.h"
#import "ASCellNode.h"
#import "ASCollectionView+Undeprecated.h"

@interface ASPagerNode () <ASCollectionDataSource, ASCollectionDelegate, ASCollectionViewDelegateFlowLayout, ASDelegateProxyInterceptor>
{
Expand Down
6 changes: 3 additions & 3 deletions AsyncDisplayKit/ASTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ASTableDelegate> asyncDelegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode's .delegate property instead.");
@property (nonatomic, weak) id<ASTableDataSource> asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode .dataSource property instead.");

/**
* Retrieves the node for the row at the given index path.
*/
Expand All @@ -66,6 +63,9 @@ NS_ASSUME_NONNULL_BEGIN

@interface ASTableView (Deprecated)

@property (nonatomic, weak) id<ASTableDelegate> asyncDelegate ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode's .delegate property instead.");
@property (nonatomic, weak) id<ASTableDataSource> asyncDataSource ASDISPLAYNODE_DEPRECATED_MSG("Use ASTableNode .dataSource property instead.");

/**
* Initializer.
*
Expand Down
14 changes: 14 additions & 0 deletions AsyncDisplayKit/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ @interface ASTableView () <ASRangeControllerDataSource, ASRangeControllerDelegat
@end

@implementation ASTableView
{
id<ASTableDelegate> _asyncDelegate;
id<ASTableDataSource> _asyncDataSource;
}

// Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASTableNode.
+ (Class)layerClass
Expand Down Expand Up @@ -299,6 +303,11 @@ - (void)setDelegate:(id<UITableViewDelegate>)delegate
ASDisplayNodeAssert(delegate == nil, @"ASTableView uses asyncDelegate, not UITableView's delegate property.");
}

- (id<ASTableDataSource>)asyncDataSource
{
return _asyncDataSource;
}

- (void)setAsyncDataSource:(id<ASTableDataSource>)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
Expand Down Expand Up @@ -338,6 +347,11 @@ - (void)setAsyncDataSource:(id<ASTableDataSource>)asyncDataSource
super.dataSource = (id<UITableViewDataSource>)_proxyDataSource;
}

- (id<ASTableDelegate>)asyncDelegate
{
return _asyncDelegate;
}

- (void)setAsyncDelegate:(id<ASTableDelegate>)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
Expand Down
18 changes: 18 additions & 0 deletions AsyncDisplayKit/Private/ASCollectionView+Undeprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ASCollectionDelegate> 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<ASCollectionDataSource> asyncDataSource;

/**
* Initializes an ASCollectionView
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#import "ASCollectionNode.h"
#import "ASCollectionViewFlowLayoutInspector.h"
#import "ASCellNode.h"
#import "ASCollectionView+Undeprecated.h"

@interface ASCollectionView (Private)

Expand Down

0 comments on commit 6565b83

Please sign in to comment.