From 43bc92df3e531e4ee7e5707a059ed28acbf4c8d7 Mon Sep 17 00:00:00 2001 From: Ferhat Ozduran Date: Sun, 2 Oct 2016 02:30:58 -0400 Subject: [PATCH] Fix for crash in Swift when long pressing an empty area. --- .../LXReorderableCollectionViewFlowLayout.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m index 9688aad..fcaf0ce 100755 --- a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m +++ b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m @@ -300,6 +300,10 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer case UIGestureRecognizerStateBegan: { NSIndexPath *currentIndexPath = [self.collectionView indexPathForItemAtPoint:[gestureRecognizer locationInView:self.collectionView]]; + if (currentIndexPath == nil) { + return; + } + if ([self.dataSource respondsToSelector:@selector(collectionView:canMoveItemAtIndexPath:)] && ![self.dataSource collectionView:self.collectionView canMoveItemAtIndexPath:currentIndexPath]) { return;