diff --git a/AsyncDisplayKit.xcworkspace/contents.xcworkspacedata b/AsyncDisplayKit.xcworkspace/contents.xcworkspacedata index 1ba280a045..574f0ec195 100644 --- a/AsyncDisplayKit.xcworkspace/contents.xcworkspacedata +++ b/AsyncDisplayKit.xcworkspace/contents.xcworkspacedata @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index 9713f267b3..ded77fe1f5 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -63,6 +63,22 @@ - (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths; - (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath; +/** + * Similar to -cellForItemAtIndexPath:. + * + * @param indexPath The index path of the requested node. + * + * @returns a node for display at this indexpath. + */ +- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath; + +/** + * Similar to -visibleCells. + * + * @returns an array containing the nodes being displayed on screen. + */ +- (NSArray *)visibleNodes; + /** * Query the sized node at `indexPath` for its calculatedSize. * diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index d7a4890ecc..149b20cab7 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -196,6 +196,19 @@ static BOOL _isInterceptedSelector(SEL sel) return [[_dataController nodeAtIndexPath:indexPath] calculatedSize]; } +- (NSArray *)visibleNodes +{ + NSArray *indexPaths = [self indexPathsForVisibleItems]; + NSMutableArray *visibleNodes = [[NSMutableArray alloc] init]; + + [indexPaths enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + ASCellNode *visibleNode = [self nodeForItemAtIndexPath:obj]; + [visibleNodes addObject:visibleNode]; + }]; + + return visibleNodes; +} + #pragma mark Assertions. - (void)insertSections:(NSIndexSet *)sections @@ -238,6 +251,10 @@ static BOOL _isInterceptedSelector(SEL sel) [_dataController moveRowAtIndexPath:indexPath toIndexPath:newIndexPath withAnimationOption:kASCollectionViewAnimationNone]; } +- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath +{ + return [_dataController nodeAtIndexPath:indexPath]; +} #pragma mark - #pragma mark Intercepted selectors. diff --git a/AsyncDisplayKit/ASTableView.h b/AsyncDisplayKit/ASTableView.h index 0b0d11bab7..2c213707e0 100644 --- a/AsyncDisplayKit/ASTableView.h +++ b/AsyncDisplayKit/ASTableView.h @@ -72,6 +72,22 @@ - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath; +/** + * Similar to -cellForRowAtIndexPath:. + * + * @param indexPath The index path of the requested node. + * + * @returns a node for display at this indexpath. + */ +- (ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath; + +/** + * Similar to -visibleCells. + * + * @returns an array containing the nodes being displayed on screen. + */ +- (NSArray *)visibleNodes; + @end diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 40c0666612..d771cc7960 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -198,6 +198,24 @@ static BOOL _isInterceptedSelector(SEL sel) _layoutController.tuningParameters = tuningParameters; } +- (ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return [_dataController nodeAtIndexPath:indexPath]; +} + +- (NSArray *)visibleNodes +{ + NSArray *indexPaths = [self indexPathsForVisibleRows]; + NSMutableArray *visibleNodes = [[NSMutableArray alloc] init]; + + [indexPaths enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + ASCellNode *visibleNode = [self nodeForRowAtIndexPath:obj]; + [visibleNodes addObject:visibleNode]; + }]; + + return visibleNodes; +} + #pragma mark Assertions. - (void)throwUnimplementedException diff --git a/Podfile.lock b/Podfile.lock index 93eb541842..acabe8b1c3 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -7,4 +7,4 @@ DEPENDENCIES: SPEC CHECKSUMS: OCMock: 6db79185520e24f9f299548f2b8b07e41d881bd5 -COCOAPODS: 0.34.4 +COCOAPODS: 0.35.0