lukescott / DraggableCollectionView

Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop. --- HELP WANTED --- Looking for maintainer and help with the experimental branch.
MIT License
549 stars 175 forks source link

Is this a typo in LSCollectionViewHelper.m ? #36

Closed unixpaul closed 10 years ago

unixpaul commented 10 years ago

Hello,

I'm just playing around with this and noticed what I think is an typo on line 236 of LSCollectionViewHelper.m . This is where the mockcell is created after the long press. Should line 236 not be [cell removeFromSuperview] instead of [mockCell removeFromSuperview] since mockCell does not yet exist ?

234           UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
235            cell.highlighted = NO;
236            [mockCell removeFromSuperview];
237            mockCell = [[UIImageView alloc] initWithFrame:cell.frame];
lukescott commented 10 years ago

Like 236 is actually redundant. At that point it should be nil. It's there to ensure that if mockCell wasn't removed previously that it is removed (and released) before overwriting the reference with a new one.

You wouldn't do [cell removeFromSuperview] because the cell's lifecycle is managed by the UICollectionView. The LSCollectionViewLayoutHelper is actually what causes the cell to be hidden (not removed).

unixpaul commented 10 years ago

Thanks Luke. Yes, I figured that out after I posted.