Permalink
Browse files
sanity check of the indexPath before insertion to prevent crashes
- Loading branch information...
|
|
@@ -115,6 +115,11 @@ - (void)updateVisibleCells |
|
|
|
|
|
|
|
- (void)adPlacer:(MPStreamAdPlacer *)adPlacer didLoadAdAtIndexPath:(NSIndexPath *)indexPath |
|
|
|
{ |
|
|
|
if (!(indexPath.section<[self.collectionView numberOfSections] && |
|
|
|
indexPath.row<[self.collectionView numberOfItemsInSection:indexPath.section])) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
BOOL animationsWereEnabled = [UIView areAnimationsEnabled]; |
|
|
|
//We only want to enable animations if the index path is before or within our visible cells |
|
|
|
BOOL animationsEnabled = ([(NSIndexPath *)[self.collectionView.indexPathsForVisibleItems lastObject] compare:indexPath] != NSOrderedAscending) && animationsWereEnabled; |
|
|
|
|
|
@@ -123,6 +123,11 @@ - (void)updateVisibleCells |
|
|
|
|
|
|
|
- (void)adPlacer:(MPStreamAdPlacer *)adPlacer didLoadAdAtIndexPath:(NSIndexPath *)indexPath |
|
|
|
{ |
|
|
|
if (!(indexPath.section<[self.tableView numberOfSections] && |
|
|
|
indexPath.row<[self.tableView numberOfRowsInSection:indexPath.section])) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
BOOL originalAnimationsEnabled = [UIView areAnimationsEnabled]; |
|
|
|
//We only want to enable animations if the index path is before or within our visible cells |
|
|
|
BOOL animationsEnabled = ([(NSIndexPath *)[self.tableView.indexPathsForVisibleRows lastObject] compare:indexPath] != NSOrderedAscending) && originalAnimationsEnabled; |
|
|
|
0 comments on commit
1d59945