kreeger / BDKCollectionIndexView

Gives a UICollectionView the sectionIndexTitles scrub bar that a UITableView gets for almost free.
MIT License
158 stars 29 forks source link

Crash when indexLabels count becomes 0 during scrolling #32

Closed stefanomondino closed 8 years ago

stefanomondino commented 8 years ago

We had some crashes in production on one of our apps, took us a while to figure this out. Scenario: we have a UICollectionView with a searchBar that filters out a list of items fetched from CoreData (I mean, data is local and there is no network involved, it's some kind of "quick-fetch") . On the right, of course we have BDKCollectionIndexView. When user query for some of the ingredients in the list, the indexView gets updated correctly. If the user types in a query with NO match, the indexView also gets updated correctly (no indexes at all), but if the user is still scrolling inside the indexView, the handleGesture method keeps on calling setNewIndexForPoint:(CGPoint)point method. Solved by adding

if (self.indexLabels.count<1) return;

at line 274 of BDKCollectionIndexView.m

Going to submit you a Pull Request ASAP