From e754cc2024d97eb99664a0bc4494dc39f6ce43a1 Mon Sep 17 00:00:00 2001 From: Nadine Salter Date: Tue, 16 Dec 2014 13:15:28 -0800 Subject: [PATCH] Add ASCellNode type assertions (closes #161). --- AsyncDisplayKit/ASCollectionView.m | 4 +++- AsyncDisplayKit/ASTableView.m | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.m b/AsyncDisplayKit/ASCollectionView.m index f66fdaab36..35682a8ae6 100644 --- a/AsyncDisplayKit/ASCollectionView.m +++ b/AsyncDisplayKit/ASCollectionView.m @@ -314,7 +314,9 @@ static BOOL _isInterceptedSelector(SEL sel) - (ASCellNode *)dataController:(ASDataController *)dataController nodeAtIndexPath:(NSIndexPath *)indexPath { - return [_asyncDataSource collectionView:self nodeForItemAtIndexPath:indexPath]; + ASCellNode *node = [_asyncDataSource collectionView:self nodeForItemAtIndexPath:indexPath]; + ASDisplayNodeAssert([node isKindOfClass:ASCellNode.class], @"invalid node class, expected ASCellNode"); + return node; } - (CGSize)dataController:(ASDataController *)dataController constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath diff --git a/AsyncDisplayKit/ASTableView.m b/AsyncDisplayKit/ASTableView.m index e97621c476..a1bcb8e48a 100644 --- a/AsyncDisplayKit/ASTableView.m +++ b/AsyncDisplayKit/ASTableView.m @@ -397,7 +397,9 @@ static BOOL _isInterceptedSelector(SEL sel) #pragma mark - ASDataControllerDelegate - (ASCellNode *)dataController:(ASDataController *)dataController nodeAtIndexPath:(NSIndexPath *)indexPath { - return [_asyncDataSource tableView:self nodeForRowAtIndexPath:indexPath]; + ASCellNode *node = [_asyncDataSource tableView:self nodeForRowAtIndexPath:indexPath]; + ASDisplayNodeAssert([node isKindOfClass:ASCellNode.class], @"invalid node class, expected ASCellNode"); + return node; } - (CGSize)dataController:(ASDataController *)dataController constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath {