Skip to content

Commit dbf2084

Browse files
author
Jim Dovey
committed
Return NSNotFound when asked for the index of a grid cell at a point outside the bounds of the grid.
1 parent 095a413 commit dbf2084

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Classes/AQGridViewData.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ - (NSUInteger) itemIndexForPoint: (CGPoint) point
9696
NSUInteger x = (NSUInteger)floorf(point.x);
9797
NSUInteger col = x / (NSUInteger)_actualCellSize.width;
9898

99-
return ( (row * [self numberOfItemsPerRow]) + col );
99+
NSUInteger result = (row * [self numberOfItemsPerRow]) + col;
100+
if ( result >= self.numberOfItems )
101+
return ( NSNotFound );
102+
103+
return ( result );
100104
}
101105

102106
- (CGRect) cellRectForPoint: (CGPoint) point

0 commit comments

Comments
 (0)