CETableViewBinding icon indicating copy to clipboard operation
CETableViewBinding copied to clipboard

How to forward UITableViewDelegate methods?

Open ektapadaliya opened this issue 10 years ago • 3 comments

I have created property in "CETableViewBindingHelper.h" file.

@property (weak, nonatomic) id delegate;

Now how to use this delegate to forward "didSelectRowAtIndexPath" method to view controller?

I have implemented below code in "CETableViewBindingHelper.m" file.

 #pragma mark = UITableViewDelegate methods

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

      // execute the command
      [_selection execute:_data[indexPath.row]];

      // forward the delegate method
      if ([self.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
           [self.delegate tableView:tableView didSelectRowAtIndexPath:indexPath];
     }
}

But "[self.delegate tableView:tableView didSelectRowAtIndexPath:indexPath];" this line is not executed.

Can you please help me that how can I forward any tableview delegate methods in my ViewController.

ektapadaliya avatar Aug 01 '16 06:08 ektapadaliya

Forwarding this method should already happen via the code here:

https://github.com/ColinEberhardt/CETableViewBinding/blob/f9981da4bb2359f62a0438c3df6fb3e30c500abe/CETableViewBindingHelper.m#L330

Are you using the latest version of the code?

ColinEberhardt avatar Aug 04 '16 08:08 ColinEberhardt

Ohh sorry I updated my code and its working fine.

Thanks for help.

ektapadaliya avatar Aug 04 '16 11:08 ektapadaliya

Nice one - glad it works now.

ColinEberhardt avatar Aug 04 '16 13:08 ColinEberhardt