title: Get tableview row on cell button tap
body: <p>I have a tableview with cells (not custom), and each cell has a button (among other things).</p>
  
  <p>Depending on the cell, the button that is created is different. I have 3 different types of cell/button, Rate/View/Edit (I'm not sure that's at all relevant)</p>
  
  <p>This button is only used for this:</p>
  
  <pre><code>[button addTarget:self action:@selector(rateEvent:) forControlEvents:UIControlEventTouchUpInside];
  </code></pre>
  
  <p>The selector is different for each button (rateEvent, viewEvent, editEvent).</p>
  
  <p>Here is an example, they're all 3 fairly similar and start the segue sequence: </p>
  
  <pre><code>- (IBAction)viewEvent:(UIButton*)sender
  {
      [self performSegueWithIdentifier:@"fromHomeToDetails" sender:self];
  }
  </code></pre>
  
  <p>My <code>didSelectedRowAtIndexPath</code> saves the details of a meeting in the <code>selectedMeeting</code> object.</p>
  
  <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
  
          selectedMeeting = [_nextMeetingsArray objectAtIndex:indexPath.row];
  }
  </code></pre>
  
  <p>The segue sends <code>selectedMeeting</code> to the next controller.</p>
  
  <p><strong>My issue :</strong> The meeting that is sent depends on the selected cell. That means the user has to select a cell and THEN tap the button to get the correct details on the next page. What can i do to get the correct indexpath of a tapped button inside a cell?</p>
  
  <p>I tried to add parameters to the viewEvent method, to make it look like <code>-(void)viewEvent:(int)index:(UIButton*)sender;</code> but it doesn't work in the <code>@selector(viewEvent:)</code>.</p>
  
  <p>The solutions i can imagine but not create are : 
  - Manage to get the indexpath of the cell of a tapped button and send it to my viewEvent method, somehow.
  - Create a customCell and/or use an accessory, so i've read here and there.
  - Force row selection when i tap the button, but that also requires to know the index of said row.</p>
  
  <p>Both seem "too complicated" for something that (should?) be fairly simple. I'm pretty sure any experienced programmer will have an obvious easy answer that I haven't learned yet, and i'd rather ask for it than implement something heavier than it should be. </p>
  
  <p>Also, if you have any comment/criticism on how i've done that, i'm all ears :)</p>
  
  <p>Thanks for your time guys, as always, i'm very grateful.</p>
  
  <p>EDIT : </p>
  
  <p>cellForRow method :</p>
  
  <p>Note : i removed everything that has to do with labeling. Because i have different buttons there are multiple if{} statements but they are of no influence in my opinion. Also, the cell is based on a storyboard cell with a tag of 228 ; after creation a new tag is set so it shouldn't influence. Also, i have a cap of 50 items in tableview (set from webservice) so there is no way the indexpath reaches >50.</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
  UITableViewCell *nextCell = [self.tbvNextMeetings dequeueReusableCellWithIdentifier:@"tbNextCell" forIndexPath:indexPath];
  UIButton *bt= (UIButton*) [nextCell viewWithTag:228];
  [bt setTitle:@"Edit" forState:UIControlStateNormal];
  [bt addTarget:self action:@selector(editEvent:) forControlEvents:UIControlEventTouchUpInside];
  [bt setTag:indexPath.row];
  
  return nextCell;
  </code></pre>