2323
2424@interface ViewController () <ASCollectionDataSource, ASCollectionViewDelegateFlowLayout>
2525
26- @property (nonatomic , strong ) ASCollectionView *collectionView ;
26+ @property (nonatomic , strong ) ASCollectionNode *collectionNode ;
2727@property (nonatomic , strong ) NSArray *data;
2828
2929@end
@@ -34,8 +34,8 @@ @implementation ViewController
3434
3535- (void )dealloc
3636{
37- self.collectionView . asyncDataSource = nil ;
38- self.collectionView . asyncDelegate = nil ;
37+ self.collectionNode . dataSource = nil ;
38+ self.collectionNode . delegate = nil ;
3939
4040 NSLog (@" ViewController is deallocing" );
4141}
@@ -50,19 +50,19 @@ - (void)viewDidLoad
5050
5151 // This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
5252 // This functionality & example project remains for users who insist on using ASCollectionView.
53- self.collectionView = [[ASCollectionView alloc ] initWithFrame: self .view.bounds collectionViewLayout: layout];
54- self.collectionView . asyncDataSource = self;
55- self.collectionView . asyncDelegate = self;
53+ self.collectionNode = [[ASCollectionNode alloc ] initWithFrame: self .view.bounds collectionViewLayout: layout];
54+ self.collectionNode . dataSource = self;
55+ self.collectionNode . delegate = self;
5656
57- self.collectionView .autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
58- self.collectionView .backgroundColor = [UIColor whiteColor ];
57+ self.collectionNode .autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
58+ self.collectionNode .backgroundColor = [UIColor whiteColor ];
5959
6060 // This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
6161 // This functionality & example project remains for users who insist on using ASCollectionView.
62- [self .collectionView registerSupplementaryNodeOfKind: UICollectionElementKindSectionHeader];
63- [self .collectionView registerSupplementaryNodeOfKind: UICollectionElementKindSectionFooter];
62+ [self .collectionNode registerSupplementaryNodeOfKind: UICollectionElementKindSectionHeader];
63+ [self .collectionNode registerSupplementaryNodeOfKind: UICollectionElementKindSectionFooter];
6464
65- [self .view addSubview :self .collectionView ];
65+ [self .view addSubnode :self .collectionNode ];
6666
6767#if !SIMULATE_WEB_RESPONSE
6868 self.navigationItem .leftItemsSupplementBackButton = YES ;
@@ -103,20 +103,20 @@ - (void)reloadTapped
103103{
104104 // This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
105105 // This functionality & example project remains for users who insist on using ASCollectionView.
106- [self .collectionView reloadData ];
106+ [self .collectionNode reloadData ];
107107}
108108
109109#pragma mark - ASCollectionView Data Source
110110
111- - (ASCellNodeBlock)collectionView : (ASCollectionView *)collectionView nodeBlockForItemAtIndexPath : (NSIndexPath *)indexPath ;
111+ - (ASCellNodeBlock)collectionNode : (ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath : (NSIndexPath *)indexPath ;
112112{
113113 NSString *text = [NSString stringWithFormat: @" [%zd .%zd ] says hi" , indexPath.section, indexPath.item];
114114 return ^{
115115 return [[ItemNode alloc ] initWithString: text];
116116 };
117117}
118118
119- - (ASCellNode *)collectionView : (ASCollectionView *)collectionView nodeForSupplementaryElementOfKind : (NSString *)kind atIndexPath : (NSIndexPath *)indexPath
119+ - (ASCellNode *)collectionNode : (ASCollectionNode *)collectionNode nodeForSupplementaryElementOfKind : (NSString *)kind atIndexPath : (NSIndexPath *)indexPath
120120{
121121 NSString *text = [kind isEqualToString: UICollectionElementKindSectionHeader] ? @" Header" : @" Footer" ;
122122 SupplementaryNode *node = [[SupplementaryNode alloc ] initWithText: text];
@@ -125,12 +125,12 @@ - (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplem
125125 return node;
126126}
127127
128- - (NSInteger )collectionView : (UICollectionView *)collectionView numberOfItemsInSection : (NSInteger )section
128+ - (NSInteger )collectionNode : (ASCollectionNode *)collectionNode numberOfItemsInSection : (NSInteger )section
129129{
130130 return 10 ;
131131}
132132
133- - (NSInteger )numberOfSectionsInCollectionView : (UICollectionView *)collectionView
133+ - (NSInteger )numberOfSectionsInCollectionView : (ASCollectionNode *)collectionNode
134134{
135135#if SIMULATE_WEB_RESPONSE
136136 return _data == nil ? 0 : 100 ;
@@ -150,7 +150,7 @@ - (void)collectionViewUnlockDataSource:(ASCollectionView *)collectionView
150150 // unlock the data source to enable data source updating.
151151}
152152
153- - (void )collectionView : (UICollectionView *)collectionView willBeginBatchFetchWithContext : (ASBatchContext *)context
153+ - (void )collectionNode : (ASCollectionNode *)collectionNode willBeginBatchFetchWithContext : (ASBatchContext *)context
154154{
155155 NSLog (@" fetch additional content" );
156156 [context completeBatchFetching: YES ];
0 commit comments