Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

app crashes when delegate not implementing some optional methods #9

Merged
merged 1 commit into from

2 participants

@siuying

should check if the delegate have implement optional method before calling them

@siuying siuying prevent crashes when delegate not implementing some optional methods …
…- should check if the delegate have implement optional method before calling them
835e499
@provideal provideal merged commit c14b4f3 into from
@provideal
Owner

Good catch. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 9, 2011
  1. @siuying

    prevent crashes when delegate not implementing some optional methods …

    siuying authored
    …- should check if the delegate have implement optional method before calling them
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 MMGridView/Classes/MMGridView.m
View
6 MMGridView/Classes/MMGridView.m
@@ -190,7 +190,7 @@ - (void)reloadData
- (void)cellWasSelected:(MMGridViewCell *)cell
{
- if (delegate) {
+ if (delegate && [delegate respondsToSelector:@selector(gridView:didSelectCell:atIndex:)]) {
[delegate gridView:self didSelectCell:cell atIndex:cell.index];
}
}
@@ -198,7 +198,7 @@ - (void)cellWasSelected:(MMGridViewCell *)cell
- (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];
}
}
Something went wrong with that request. Please try again.