title: Calling a custom UIButton function in didSelectRowAtIndexPath
body: <p>Can anyone tell me how to call a custom function created for a <code>UIButton</code> clicked inside a cell in a didSelectRowAtIndexPath. I have a shopping cart button in a tableViewCell, when clicked I am changing the icon and maintaining a shopping cart list which works fine. But what I am trying to achieve is when user clicks on any row this functionality of <code>UIButton</code> can be used as well. </p>
  
  <p>I have written a following Code in cellForRowAtIndexPath </p>
  
  <pre><code>cell.addToCardButton.tag = indexPath.row;
  [cell.addToCardButton addTarget:self action:@selector(CartTapped:) forControlEvents:UIControlEventTouchUpInside];
  
  //cartTapped function defination
  - (void)CartTapped:(UIButton*)sender {
      NSUInteger index = sender.tag;
      Product *product = [results objectAtIndex:index];
      NSIndexPath *ip = [NSIndexPath indexPathForRow:index inSection:0];
  
      if(sender.selected) {
          UIImage *btnImage = [UIImage imageNamed:@"AddCart.png"];
          [sender setImage:btnImage forState:UIControlStateNormal];
          [BasketObjects delete:product] ;
  
      } else {
  
          sender.imageView.image =[UIImage imageNamed:@"ClearCart.png"];
          [[BasketObjects sharedInstance].basketObjects addObject:product];
      }
  
      [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:ip] withRowAnimation:UITableViewRowAnimationMiddle];
  }
  </code></pre>