Skip to content
Browse files

Merge pull request #9 from pburleson/master

Crash if UIActionSheet dismissed from touch outside popover on iPad
  • Loading branch information...
2 parents e4268ac + 20e6a63 commit d3a2bb6f813c9e5284bc69d8ef5e9cb0b68176bb @jivadevoe committed Dec 6, 2011
Showing with 9 additions and 5 deletions.
  1. +9 −5 UIActionSheet+Blocks.m
View
14 UIActionSheet+Blocks.m
@@ -69,11 +69,15 @@ - (NSInteger)addButtonItem:(RIButtonItem *)item
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
- NSArray *buttonsArray = objc_getAssociatedObject(self, RI_BUTTON_ASS_KEY);
- RIButtonItem *item = [buttonsArray objectAtIndex:buttonIndex];
- if(item.action)
- item.action();
- objc_setAssociatedObject(self, RI_BUTTON_ASS_KEY, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ if (buttonIndex != -1)
+ {
+ NSArray *buttonsArray = objc_getAssociatedObject(self, RI_BUTTON_ASS_KEY);
+ RIButtonItem *item = [buttonsArray objectAtIndex:buttonIndex];
+ if(item.action)
+ item.action();
+ objc_setAssociatedObject(self, RI_BUTTON_ASS_KEY, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+
[self release]; // and release yourself!
}

0 comments on commit d3a2bb6

Please sign in to comment.
Something went wrong with that request. Please try again.