kolinkrewinkel/KKGridView — Issue #107: Calling willSelectItemAtIndexPath with invalid index path
Author: zoul
Created: 2012-02-16 14:53:19+00:00
State: open

The `gridView:willSelectItemAtIndexPath:` delegate callback may be called with `NSNotFound` in `[indexPath index]` or `[indexPath section]`. (The stack trace is `_handleSelection` in `KKGridView` that calls `indexPathForItemAtPoint` where the index path with `NSNotFound` is created.) I don’t think it’s appropriate to call the delegate if we know the user is not selecting anything. Could we simply solve this by adding another condition on line 1406? Something like:

if (_delegateRespondsTo.willSelectItem && [indexPath index] != NSNotFound)
indexPath = [_gridDelegate gridView:self willSelectItemAtIndexPath:indexPath];

Happy to send a pull request.