Skip to content

Commit

Permalink
Merge pull request #13 from pomu0325/delegate
Browse files Browse the repository at this point in the history
tableView:accessoryButtonTappedForRowWithIndexPath: should be accessed through UITableViewDelegate
  • Loading branch information
bitmapdata committed Feb 8, 2017
2 parents ea5caf8 + 0aa7104 commit d9ec0b2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
8 changes: 4 additions & 4 deletions MSCellAccessory/MSCellAccessory.m
Expand Up @@ -259,14 +259,14 @@ - (void)layoutSubviews
- (void)accessoryButtonTapped:(id)sender event:(UIEvent *)event
{
UITableView *superTableView = [self ms_firstTableViewHierarchyFromView:self];
UITableViewController *superController = (UITableViewController *)superTableView.ms_firstAvailableUIViewController;;
id<UITableViewDelegate> tableDelegate = superTableView.delegate;
UITableViewCell *superTableViewCell = [self ms_firstTableViewCellInHierarchyFromView:self];;
NSIndexPath *indexPath = [superTableView indexPathForCell:superTableViewCell];

if ([superController respondsToSelector:@selector(tableView:accessoryButtonTappedForRowWithIndexPath:)]) {
[superController tableView:superTableView accessoryButtonTappedForRowWithIndexPath:indexPath];
if ([tableDelegate respondsToSelector:@selector(tableView:accessoryButtonTappedForRowWithIndexPath:)]) {
[tableDelegate tableView:superTableView accessoryButtonTappedForRowWithIndexPath:indexPath];
} else {
NSAssert(0, @"superController must implement tableView:accessoryButtonTappedForRowWithIndexPath:");
NSAssert(0, @"superTableView.delegate must implement tableView:accessoryButtonTappedForRowWithIndexPath:");
}
}

Expand Down
3 changes: 0 additions & 3 deletions MSCellAccessory/UIView+AccessViewController.h
Expand Up @@ -40,9 +40,6 @@

@interface UIView (AccessViewController)
- (UIViewController *)viewController DEPRECATED_ATTRIBUTE;
// Thanks to Phil M
// http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview-on-iphone
- (UIViewController *)ms_firstAvailableUIViewController;
- (id)ms_traverseResponderChainForUIViewController;
- (UITableView *)ms_firstTableViewHierarchyFromView:(UIView *)view;
- (UITableViewCell *)ms_firstTableViewCellInHierarchyFromView:(UIView *)view;
Expand Down
4 changes: 0 additions & 4 deletions MSCellAccessory/UIView+AccessViewController.m
Expand Up @@ -18,10 +18,6 @@ - (UIViewController *)viewController;
return nil;
}
}
- (UIViewController *)ms_firstAvailableUIViewController {
// convenience function for casting and to "mask" the recursive function
return (UIViewController *)[self ms_traverseResponderChainForUIViewController];
}

- (id)ms_traverseResponderChainForUIViewController {
id nextResponder = [self nextResponder];
Expand Down

0 comments on commit d9ec0b2

Please sign in to comment.