File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
LXReorderableCollectionViewFlowLayout Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -264,10 +264,11 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)theLongPressGestu
264264 [theStrongSelf.currentView removeFromSuperview ];
265265 [theStrongSelf invalidateLayout ];
266266
267- if ([self .collectionView.delegate conformsToProtocol: @protocol (LXReorderableCollectionViewDelegateFlowLayout)]) {
268- id <LXReorderableCollectionViewDelegateFlowLayout> theDelegate = (id <LXReorderableCollectionViewDelegateFlowLayout>)self.collectionView .delegate ;
267+ // Use theStrongSelf in case self has been deallocated before the completion block gets called.
268+ if ([theStrongSelf.collectionView.delegate conformsToProtocol: @protocol (LXReorderableCollectionViewDelegateFlowLayout)]) {
269+ id <LXReorderableCollectionViewDelegateFlowLayout> theDelegate = (id <LXReorderableCollectionViewDelegateFlowLayout>)theStrongSelf.collectionView .delegate ;
269270 if ([theDelegate respondsToSelector: @selector (collectionView:layout:didEndReorderingAtIndexPath: )]) {
270- [theDelegate collectionView: self .collectionView layout: self didEndReorderingAtIndexPath: theIndexPathOfSelectedItem];
271+ [theDelegate collectionView: theStrongSelf .collectionView layout: theStrongSelf didEndReorderingAtIndexPath: theIndexPathOfSelectedItem];
271272 }
272273 }
273274 }];
You can’t perform that action at this time.
0 commit comments