Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find indexPath for tapped accessory button in tableView
    primarykey
    data
    text
    <p>I've simple <code>UITableView</code> with one section and few rows. When user clicks cell accessory button (which is connected with <code>detailsSegue</code>. I want to know what cell row was it. So than I can select right object from my array and assign it to the variable from the next view. </p> <p>I have used delegate method <code>tableview:accessoryButtonTappedForRowWithIndexPath:</code> and assigned indexPath value to my private property <code>myRow</code>. Than in <code>prepareForSegue:sender:</code> method I used my <code>self.myRow.row</code> value to select right object from array. </p> <p>My problem is that these two methods seems to execute in wrong order. From the NSLog I can see that <code>prepareForSegue:sender:</code> method is executed first and my delegate method is changing value of <code>self.myRow</code> after it. </p> <p>So <code>prepareForSegue:sender:</code> method is always passing wrong object to the next view (the one that was tapped previously).</p> <p>Sorry for my english guys. Thanks for help in advance.</p> <pre><code>-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { self.myRow = indexPath; NSLog(@"tapped button at row: %i",self.myRow.row); } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([segue.identifier isEqualToString:@"addSegue"]) { AddViewController *avc = segue.destinationViewController; avc.delegate = self; } else if ([segue.identifier isEqualToString:@"detailsSegue"]) { NSLog(@"Segue row: %i",self.myRow.row); Annotation *annotation = [self.viewsList objectAtIndex:self.myRow.row]; NSLog(@"Segue annotation object: %@",annotation.title); DetailsViewController *dvc = segue.destinationViewController; dvc.wikiKey = annotation.title; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload