Skip to content

Commit 5609c90

Browse files
authored
Merge pull request #108 from ferhatozduran/bug/long-press-nil-index-path
Fix for crash in Swift when long pressing an empty area.
2 parents 2bda815 + 43bc92d commit 5609c90

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
300300
case UIGestureRecognizerStateBegan: {
301301
NSIndexPath *currentIndexPath = [self.collectionView indexPathForItemAtPoint:[gestureRecognizer locationInView:self.collectionView]];
302302

303+
if (currentIndexPath == nil) {
304+
return;
305+
}
306+
303307
if ([self.dataSource respondsToSelector:@selector(collectionView:canMoveItemAtIndexPath:)] &&
304308
![self.dataSource collectionView:self.collectionView canMoveItemAtIndexPath:currentIndexPath]) {
305309
return;

0 commit comments

Comments
 (0)