collectionView

This commit is contained in:
Hannah Trosi
2016-11-17 16:46:07 +09:00
parent c9143fb5df
commit 6565b8348d
7 changed files with 69 additions and 23 deletions

View File

@@ -38,24 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@interface ASCollectionView : UICollectionView @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 * Returns the corresponding ASCollectionNode
* *
@@ -138,6 +120,24 @@ NS_ASSUME_NONNULL_BEGIN
@interface ASCollectionView (Deprecated) @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 * Initializes an ASCollectionView
* *

View File

@@ -224,8 +224,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
@end @end
@implementation ASCollectionView @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. // Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASCollectionNode.
+ (Class)layerClass + (Class)layerClass
@@ -363,6 +365,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
} }
} }
- (id<ASCollectionDataSource>)asyncDataSource
{
return _asyncDataSource;
}
- (void)setAsyncDataSource:(id<ASCollectionDataSource>)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 // 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<ASCollectionDelegate>)asyncDelegate
{
return _asyncDelegate;
}
- (void)setAsyncDelegate:(id<ASCollectionDelegate>)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 // Note: It's common to check if the value hasn't changed and short-circuit but we aren't doing that here to handle

View File

@@ -16,6 +16,7 @@
#import "ASPagerFlowLayout.h" #import "ASPagerFlowLayout.h"
#import "ASAssert.h" #import "ASAssert.h"
#import "ASCellNode.h" #import "ASCellNode.h"
#import "ASCollectionView+Undeprecated.h"
@interface ASPagerNode () <ASCollectionDataSource, ASCollectionDelegate, ASCollectionViewDelegateFlowLayout, ASDelegateProxyInterceptor> @interface ASPagerNode () <ASCollectionDataSource, ASCollectionDelegate, ASCollectionViewDelegateFlowLayout, ASDelegateProxyInterceptor>
{ {

View File

@@ -38,9 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
/// The corresponding table node, or nil if one does not exist. /// The corresponding table node, or nil if one does not exist.
@property (nonatomic, weak, readonly) ASTableNode *tableNode; @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. * Retrieves the node for the row at the given index path.
*/ */
@@ -66,6 +63,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface ASTableView (Deprecated) @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. * Initializer.
* *

View File

@@ -197,6 +197,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
@end @end
@implementation ASTableView @implementation ASTableView
{
id<ASTableDelegate> _asyncDelegate;
id<ASTableDataSource> _asyncDataSource;
}
// Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASTableNode. // Using _ASDisplayLayer ensures things like -layout are properly forwarded to ASTableNode.
+ (Class)layerClass + (Class)layerClass
@@ -299,6 +303,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
ASDisplayNodeAssert(delegate == nil, @"ASTableView uses asyncDelegate, not UITableView's delegate property."); ASDisplayNodeAssert(delegate == nil, @"ASTableView uses asyncDelegate, not UITableView's delegate property.");
} }
- (id<ASTableDataSource>)asyncDataSource
{
return _asyncDataSource;
}
- (void)setAsyncDataSource:(id<ASTableDataSource>)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 // 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<UITableViewDataSource>)_proxyDataSource; super.dataSource = (id<UITableViewDataSource>)_proxyDataSource;
} }
- (id<ASTableDelegate>)asyncDelegate
{
return _asyncDelegate;
}
- (void)setAsyncDelegate:(id<ASTableDelegate>)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 // Note: It's common to check if the value hasn't changed and short-circuit but we aren't doing that here to handle

View File

@@ -19,6 +19,24 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@interface ASCollectionView (Undeprecated) @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 * Initializes an ASCollectionView
* *

View File

@@ -16,6 +16,7 @@
#import "ASCollectionNode.h" #import "ASCollectionNode.h"
#import "ASCollectionViewFlowLayoutInspector.h" #import "ASCollectionViewFlowLayoutInspector.h"
#import "ASCellNode.h" #import "ASCellNode.h"
#import "ASCollectionView+Undeprecated.h"
@interface ASCollectionView (Private) @interface ASCollectionView (Private)