Permalink
Browse files

Merge pull request #9 from siuying/master

app crashes when delegate not implementing some optional methods
  • Loading branch information...
2 parents 2747bc5 + 835e499 commit c14b4f3d03aa42e3fa5a1164334c554996e7ae9f @provideal committed Jul 12, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 MMGridView/Classes/MMGridView.m
View
6 MMGridView/Classes/MMGridView.m
@@ -190,15 +190,15 @@ - (void)reloadData
- (void)cellWasSelected:(MMGridViewCell *)cell
{
- if (delegate) {
+ if (delegate && [delegate respondsToSelector:@selector(gridView:didSelectCell:atIndex:)]) {
[delegate gridView:self didSelectCell:cell atIndex:cell.index];
}
}
- (void)cellWasDoubleTapped:(MMGridViewCell *)cell
{
- if (delegate) {
+ if (delegate && [delegate respondsToSelector:@selector(gridView:didDoubleTapCell:atIndex:)]) {
[delegate gridView:self didDoubleTapCell:cell atIndex:cell.index];
}
}
@@ -210,7 +210,7 @@ - (void)updateCurrentPageIndex
NSUInteger cpi = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
self.currentPageIndex = cpi;
- if (delegate) {
+ if (delegate && [delegate respondsToSelector:@selector(gridView:changedPageToIndex:)]) {
[self.delegate gridView:self changedPageToIndex:self.currentPageIndex];
}
}

0 comments on commit c14b4f3

Please sign in to comment.